SMTP服务器响应:550 - 当前不允许通过此服务器中继550

时间:2011-03-18 17:50:11

标签: php email smtp

我正在使用php mail()通过SMTP发送电子邮件 但是,当我从example@example.com发送邮件时,我收到了以下错误,

  

警告:mail()[function.mail]:SMTP服务器响应:550-(ABC-7d3b78ff)[117.98.220.45]:目前不允许1747通过此服务器中继550。也许您还没有在过去30分钟内登录pop / imap服务器550,或者您的550电子邮件客户端未启用SMTP身份验证。

这是我的代码的问题,还是我需要在服务器端进行更改?

这是我的代码:

$header .= "\r\nMIME-Version: 1.0";
$header .= "\r\nContent-type: text/html; charset=iso-8859-1\r\n";

$from    = $row["fromid"];
$to      = $row["email_addr"]; // abc@yahoo.com sending to other than same domain mail
$subject = $row["subject"];

mail($to,$subject,$body,$header);

2 个答案:

答案 0 :(得分:2)

使用mail()时,服务器上的PHP似乎配置为与SMTP服务器通信。该错误消息表明您的SMTP服务器要求您执行直接身份验证,或者您要执行POP-before-SMTP身份验证。如果您是共享主机,我赞扬您的网络托管服务提供商非常聪明。

正如评论中所提到的SwiftMailer是一个功能强大且易于使用的邮件库,其中包含the ability to perform SMTP authentication。有些人还建议使用PHPMailerPEAR's Mail,这两者都可以执行SMTP身份验证。

答案 1 :(得分:1)

只需在php中添加以下行即可解决此问题:

    ini_set(sendmail_from,'yourmail@abc.com');

因此您的代码将变为:

    $header .= "\r\nMIME-Version: 1.0";
    $header .= "\r\nContent-type: text/html; charset=iso-8859-1\r\n";

    $from    = $row["fromid"];
    $to      = $row["email_addr"]; // abc@yahoo.com sending to other than same domain mail
    $subject = $row["subject"];

    ini_set(sendmail_from,'yourmail@abc.com');
    mail($to,$subject,$body,$header);