PHP Email Script不会发送电子邮件

时间:2016-05-01 18:49:49

标签: php html forms email

我有一个php脚本来发送包含HTML表单数据的电子邮件。 电子邮件不发送,并且两组代码都在if语句中执行:

不确定我是否错过了EOL封口作为php新手。 任何输入赞赏。

<?php
if(!$_POST) exit;

    $to       = 'myemail.com'; 
    $name     = $_POST['txtname'];
    $email    = $_POST['txtemail'];
    $subject  = 'Support';
    $comment  = $_POST['txtmessage'];

    if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); }

     $e_subject = 'You\'ve been contacted by ' . $name . '.';

     $msg  = "You have been contacted by $name with regards to $subject.\r\n\n";
     $msg .= "$comment\r\n\n";
     $msg .= "You can contact $name via email, $email.\r\n\n";
     $msg .= "-------------------------------------------------------------------------------------------\r\n";

     if(@mail($to, $e_subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"))
     {

// THiS CODE EXECUTES
         echo "<div class='dt-sc-success-box aligncenter'> <span></span> <h4> Success </h4> Thanks for <b>Contacting Us</b>, We will call back to you soon.</div>";

     }
     else
     {

// THIS CODE EXCUTES
         echo '<div class="dt-sc-error-box aligncenter"> <span></span> <h4> Error </h4> Sorry your message <b>not sent</b>, Try again Later. </div>';
     }
?>

0 个答案:

没有答案