0

My contact form was working, and now, out of nowhere, I cannot receive the messages that are being sent from it.

Here's my PHP code for the form :

    if($_POST){

    $to = "MY EMAIL HERE";
    $subject = "Formulaire de contact - Orizon Ventes FRANÇAIS";
    $message = "<h2>$subject</h2>
                <b>Nom:</b> $_POST[nom]<br/>
                <b>Courriel:</b> $_POST[courriel]<br/>
                <b>Telephone:</b> $_POST[phone]<br/>
                <b>Message:</b> $_POST[message]<br/>";

    $merci = "Merci! Votre message a bien été envoyé.";

    // if($_POST[nom]==""){$err .= "Le champ \"NOM\" ne peut pas &#234;tre vide<br/>";}
    // if($_POST[email]==""){$err .= "Le champ \"EMAIL\" doit &#234;tre s&#233;lectionn&#233;<br/>";}
    // if($_POST[message]==""){$err .= "Le champ \"MESSAGE\" ne peut pas &#234;tre vide<br/>";}
    //if( $_SESSION['security_code'] != $_POST['security_code'] && $_SESSION['security_code'] !="" ) { $err .= "Le champ \"CODE DE S&#201;CURIT&#201;\" n'est pas valide<br>"; }

    if($err==""){

            $headers = "MIME-Version: 1.0\n" ;
            $headers .= "Content-Type: text/html; charset=\"utf-8\"\n";
            $headers .= "De: $_POST[nom]\n";
            $headers .= "To: $to\n";
            $headers .= "X-Priority: 1 (Higuest)\n";
            $headers .= "X-MSMail-Priority: High\n";
            $headers .= "Importance: High\n";

            $status   = mail($to, $subject, $message, $headers);
            echo "<div class='thanks'>".$merci."<br/><br/></div>";
            unset($_POST);

    }
    }
    if($err!=""){
    echo "<div class='erreur'>".$err."<br/><br/></div>";
    }
    ?>

When I click the send button, I get the success message, but I'm not receiving the message on my email. 1 - Is there a way to retrieve these sent messages? 2 - How to fix this?

Thanks a lot!

larin555
  • 1,669
  • 4
  • 28
  • 43

1 Answers1

0

Most mail providers - such as Google, Yahoo, Microsoft - tend to filter out messages generated by php.mail(). Many have seen success using PEAR Mail libraries, which requires you to actually login to the smtp server when sending.

For example: if you log into gmail and send an email, Google (gmail) probably won't filter it out of your inbox.

Mail - Pear - PHP

StackOverflow: sending email with php

Community
  • 1
  • 1
chriswirz
  • 278
  • 1
  • 9
  • Thanks for the info. So what should I change in my PHP code? Should I just change it all to something else? – larin555 Mar 30 '16 at 14:36
  • Well, the regular mail library will not work for you. Take a look at this stackoverfow question which has the answer to your question: http://stackoverflow.com/questions/14456673/sending-email-with-php-from-an-smtp-server – chriswirz Mar 30 '16 at 17:25