0

I am trying to figure out why the contact form is not working anymore. But the code seems to be fine. This is the beginning of the code I added for the contact form.

  <?php
if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "test@test.com";
    $email_subject = "Contact Form";

    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

And this is the last part of the code:

 // create email headers
$headers = 'From:reply@test.com' . "\r\n" .
    'Reply-To: '.$email_from. "\r\n" .
    'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);

?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.


<?php
}
?>

Any ideas what might be the problem here? Thank you!

Lisa
  • 1
  • 2
  • 1
    Do you have php logs? What is the sender address? Often Google for instance disables the 'unsafe' setting of allowing mails to be sent from apps. – Sven Jan 17 '22 at 14:13
  • 1
    Please elaborate on "not working". Remove the `@` in front of your `email()` usage and [enable PHP error reporting](https://stackoverflow.com/a/21429652/231316), for debugging you want to see these messages. Check out the canonical [PHP-email issues troubleshooting answer](https://stackoverflow.com/a/24644450/231316). – Chris Haas Jan 17 '22 at 15:19

0 Answers0