php邮件不是从联系表单发送的

时间:2013-11-25 18:42:25

标签: php forms email post

我已经在本教程的帮助下整理了一个带有验证的表单:http://www.w3resource.com/php/form/php-form-validation.php

我希望有人可以指出我哪里出错了?正如我的验证工作,我得到一条谢谢你的消息,但没有邮件进入我的收件箱:(

<?php        
if (isset($_POST['submit'])) {        
    //checking name        
    if(empty($_POST['full_name']))        
    $msg_name = "*";        
    $name_subject = $_POST['full_name'];        
    //check phone number        
    if(empty($_POST['Phone_Num']))        
    $msg_Phone = "*";        
    $email_subject = $_POST['Phone_Num'];        
    //check email        
    if(empty($_POST['email_addr']))        
    $msg_email = "*";        
    $email_subject = $_POST['email_addr'];        
    $email_pattern = '/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/';        
    preg_match($email_pattern, $email_subject, $email_matches);        
    if(!$email_matches[0])        
    $msg2_email = "Please enter a valid email address";
}           
// validation complete         
if(isset($_POST['submit'])){        
    if($msg_name=="" && $msg2_name=="" && $msg_email=="" && $msg2_email=="" &&         $msg2_Message=="")        
    $msg_success = "Thankyou for your enquiry";        
    //send mail           
    $to = "someone@email.com";          
    $subject = "Data collected thorugh from";          
    $message = "<p>".$_POST["full_name"]."</p><p>".$_POST["Phone_Num"]."        </p><p>".$_POST["email_addr"]."</p><p>".$_POST["Message"]."</p>";
    $from = "someone@email.com";          
    mail($to,$subject,$message);          
}        
?>

1 个答案:

答案 0 :(得分:0)

PHP mail()函数不允许通过SMTP通过身份验证发送电子邮件。如果你想这样做,有一个PEAR包。

This article给出了一些解释。