0

Not a PHP expert. With that said, I've used this system before and it seemed to stop working one day. I can't seem to get emails sent anymore even if I'm not getting any error messages. I don't know what's wrong.

Form page:

<form method="POST" name="contactform" action="contact-form-handler.php"> 

<label for='name'>Your Name:</label> <br>
<input type="text" name="name">

<label for='email'>Email Address:</label> <br>
<input type="text" name="email"> <br>



What does this concern?<br> 
<select name="options">
<option value="null">--</option>
<option value="IEP">IEP</option>
<option value="Section 504">Section 504</option>
<option value="Other">Other</option>
</select>


<p style="width: 50%">Please include in your message what type of service you are inquiring about. Please be as descriptive as possible so we can help you more efficiently. Thank you.</p>


<label for='message'>Message:</label> <br>
<textarea name="message" cols="45" rows="7"></textarea>

<input type="image" src="img/submit.png" alt="Submit"> <br>
</form>

Handling:

<?php 
$errors = '';
$myemail = 'louie540x@gmail.com;';
if(empty($_POST['name'])  || 
   empty($_POST['email']) ||
   empty($_POST['options']) || 
   empty($_POST['message']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['name'];
$email_address = $_POST['email']; 
$message = $_POST['message']; 
$options = $_POST['options']; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
    $to = $myemail; 
    $email_subject = "Contact form submission: $name";
    $email_body = "You have received a new message. ".
    " Here are the details:\n Name: $name \n Email:     $email_address \n Regarding a(n): $options \n \n Message: \n \n $message"; 

$headers = "From: $myemail\n"; 
$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.php');
} 
?>

<?php include 'template/top.php'; ?>

<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>

<?php include 'template/bottom.php'; ?>
  • 1
    Possible duplicate of [PHP mail form doesn't complete sending e-mail](http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail) – Chris Mar 27 '16 at 00:31
  • Gmail is *very* picky when it comes to receiving emails from unauthorized senders. Are you using Gmail's SMTP to send the email? (not from what I can see but maybe there is some other code) If not that could very well be your issue. – Technoh Mar 27 '16 at 02:20

1 Answers1

1
$myemail = 'louie540x@gmail.com;';

Should be:

$myemail = 'louie540x@gmail.com';

However that may not be your only problem...

TheFrack
  • 2,823
  • 7
  • 28
  • 47