PHP邮件函数未发送,代码有问题


PHP Mail function not sending, something wrong with code

im使用linux系统

我在我的网站上尝试了一个测试邮件php脚本,它可以与该脚本配合使用。但出于某种原因不是我的。有人看到什么不对吗?

        $title = "Confirmation Required";   
        $msg = "An email has been sent to you with a confirmation link and your password.  Once clicking the link you will be asked to change your password and you will be ready to start earning!.<br><center><h2>The email was sent to <strong>$email</strong>.</h2></center><center>Go Check Your Email And Confirm Your Account</center><br>";
    $to = $email;
    $subject = "Confirm New Account";
    $message = "<h2>Welcome</h2> <h4><a href='$siteUrl/confirm.php?key=$userId'> Click Here To Confirm Account </a></h4> Your login information.<br>Login: <strong>$email</strong> <br> Password: <strong>$userId</strong>";
$headers .= "X-Mailer: PHP 'r'n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
$headers .= 'To: Member <$email>' . "'r'n";
$headers .= 'From:  <' . $adminEmail. '>' . "'r'n";
    mail($to,$subject,$message,$headers);

    } // all good  
    echo "Mail sent OK";
    } 

这是我的php.ini文件

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t;
sendmail_from = Contact@mysite.com

尝试更改此行:

$headers .= 'To: Member <$email>' . "'r'n";

对此:

$headers .= 'To: Member <' . $email . '>' . "'r'n";

可能是邮件服务器坏了。我以前遇到过这个问题,它一直在工作,然后突然停止了工作。请检查一下:PHP邮件突然停止工作

或者,可能是您的邮件配置设置错误。