简体   繁体   中英

Form doesn't send email to some addresses

I'm having a problem with my simple form script which always send to my previous email address, now doesn't send to my new one. Is it because there's a dash in the address? Here's the script:

<?php 

if ($_POST["email"] <> '') {
    $ToEmail = 'info@xxx-xxx.com';
    $EmailSubject = 'Site contact form '; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=utf-8\r\n"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
    $MESSAGE_BODY .= "Telephone: ".$_POST["tel"]."<br>";
    $MESSAGE_BODY .= "Type: ".$_POST["type"]."<br>";
    $MESSAGE_BODY .= "Subject: ".$_POST["subject"]."<br>";
    $MESSAGE_BODY .= "Hours per week: ".$_POST["hours"]."<br>";
    $MESSAGE_BODY .= "Additional information: ".nl2br($_POST["info"])."<br>"; 

    // HAS THE SPAM TRAP FIELD BEEN FILLED IN?

    if( !empty( $_POST['random'] ) )
    {exit;}

    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 

?> 

<html>

    <h3>Thank you for your email</h3>
    <h4>I'll get back to you as soon as possible</h4>
    <a href="index.html"><p>Click here to go back to the home page</p></a>

</html>


<?php 
} else { 
?> 

<html>Sorry, this form didn't work</html>

Any help would be appreciated. Thanks

It is probably getting caught in a spam filter on the receiving end. Add the sender email address in your script to your new email's white list and see if that helps.

Did you migrate from a Gmail to a Yahoo account? The dash should not make any difference. Certain email providers (esp. Yahoo) have problems with emails being sent using the mail command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM