Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:12:57+00:00 2026-05-31T19:12:57+00:00

Hi im having problems with my PHP code for sending an email via a

  • 0

Hi im having problems with my PHP code for sending an email via a contact form. I am getting no errors and can see no problem with the code after researching it thoroughly, could someone help me??

<?php

// Define some constants
define( "RECIPIENT_NAME", "Nuim Buzz" );
define( "RECIPIENT_EMAIL", "nuimbuzz@gmail.com" );
define( "EMAIL_SUBJECT", "Visitor Message" );

// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/",   "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$senderMessage = isset( $_POST['senderMessage'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['senderMessage'] ) : "";

// If all values exist, send the email
if ( $senderName && $senderEmail && $senderMessage ) {
  $recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
  $headers = "From: " . $senderName . " <" . $senderEmail . ">";
  $success = mail( $recipient, EMAIL_SUBJECT, $senderMessage, $headers );
}


?>
<html>
  <head>
    <title>Thanks!</title>
  </head>
  <body>
  <?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
  <?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
  <p>Click your browser's Back button to return to the page.</p>
  </body>
</html>

The HTML code:

  <h2>Send us an email...</h2>

  <ul>

    <li>
      <label for='senderName'>Your Name</label>
      <input type='text' name='senderName' id='senderName' placeholder='Please type your name...' required='required' maxlength='40' />
</li>

<li>
  <label for='senderEmail'>Your Email Address</label>
  <input type='email' name='senderEmail' id='senderEmail' placeholder='Please type your email address...' required='required' maxlength='50' />
</li>

<li>
  <label for='message' style='padding-top: .5em;'>Your Message</label>
  <textarea name='senderMessage' id='message' placeholder='Please type your message...' required='required' cols='80' rows='10' maxlength='10000'></textarea>
</li>

  </ul>

  <div id='formButtons'>
    <input type='submit' id='sendMessage' name='sendMessage' value='Send Email' />

  </div>

</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:12:58+00:00Added an answer on May 31, 2026 at 7:12 pm

    It seems your problem is server setup. Are you local? Are you on a shared hosting plan? If the latter you may have a domain problem, so contact your hosting solution to ensure you have it set up right. Also check your server error logs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble sending emails with PHP. Can you see any problems in
I am using Uploadify and am having problems submitting a form to uploaded1.php after
I am having problems with this code: <?php $new_value = 'testing'; $con = mysql_connect(localhost,user,pass);
I'm having a problem with some code that used to work in PHP 4.X
I'm having a problem with a query prepared in PHP with PDO. The code:
Hello I'm having problems sending arrays, structs and arrays of structs from PHP to
I am having problems implementing my PHP/MySQL code into a jgrowl. If you are
I am having problems calling a URL from PHP code. I need to call
I'm having problems with the hosts file and PHP. When running the PHP code
i'm having Problem with sending Email in Persian. It's Ok on gmail, all of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.