php邮件未发送

时间:2012-12-19 02:53:00

标签: php email

这是我的代码

$subject = "Welcome to Last Alliance Standing";
$message = "$name Welcome to Last Alliance Standing, Your account has been registered and you are now able to login and play";
$headers  = "From: Team Laser<noreply@lastalliancestanding.com>\r\n";
$headers .= "X-Mailer: Drupal\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

if (mail($email, $subject, $message, $headers)) {   
    header("location: passwordrequest-success.php");
    exit();
} else {
    echo "Not Sent";    
}

电子邮件并不总是发送,虽然有时会发送,但有时我会收到“未发送”错误

3 个答案:

答案 0 :(得分:0)

您要做的第一件事是检查您的服务器是否支持邮件功能。之后,您可以将mail()放入try {} catch(){}以捕获错误代码:)

答案 1 :(得分:0)

如果您的主机使用Windows系统,更改此行可能有帮助

$headers  = "From: Team Laser<noreply@lastalliancestanding.com>\r\n";
$headers  = "From: noreply@lastalliancestanding.com\r\n";

另外,$email 的格式应为Alias <mail@ress.com>

答案 2 :(得分:0)

感谢那些有提示的人,我联系了服务台(今天第四次)并最终到了某个地方,因为它是一个共享帐户,其中一个帐户发送了大量垃圾邮件,现在已经固定,但感谢大家试图帮助