【问题标题】:Sending mail from PHP script results in error从 PHP 脚本发送邮件会导致错误
【发布时间】:2009-02-03 02:44:20
【问题描述】:

我有一个脚本,以前似乎可以工作,但现在不行了。

脚本运行后显示此消息:

Array (
    [0] => Unrouteable address [1] => -All RCPT commands were rejected with this error:\\
    503-Unrouteable address 503 valid RCPT command must precede DATA
)
Array (
    [0] => Unrouteable address [1] => -All RCPT commands were rejected with this error:\\
    503-Unrouteable address 503 valid RCPT command must precede DATA
)
Array (
    [0] => Unrouteable address [1] => -All RCPT commands were rejected with this error:\\
    503-Unrouteable address 503 valid RCPT command must precede DATA
)

实际功能:

function emailUser($table, $subject, $message) {
    $query = "SELECT * FROM $table";
    $result=mysql_query($query);

    while($row = mysql_fetch_array($result)) {
        $i = 0;

        while($i <= 0) {
            $to = $row['email'];
            $to_all .= '<li>'.$row['email'].'</li>';
            $mail = new htmlMimeMail();
            $mail->setHTML($message);
            $mail->setSubject($subject);
            $mail->setSMTPParams('mail.site.net', 25, 'site.net');
            $mail->setReturnPath("email@site.net");
            $mail->setFrom("email@site.net");

            $mail_result = $mail->send(array($to), 'smtp');

            if (!$mail_result) {
                    print_r($mail->errors);
                    //failure
                } else {
                    //success
                }
            $i++;
        }
    }
    print '<h3>Mail successuly sent to:</h3>';
    print '<ul>'.$to_all.'</ul>';
}

有没有更好的脚本可以使用?可能是邮箱服务器变了?

感谢任何帮助。

【问题讨论】:

  • 首先想到的是检查电子邮件地址的有效性。但是,除此之外,内部 while 循环 ("$i

标签: php email


【解决方案1】:

尝试重新排序到以下内容(setHTML 在末尾):

$mail->setSubject($subject);
$mail->setSMTPParams('mail.site.net', 25, 'site.net');
$mail->setReturnPath("email@site.net");
$mail->setFrom("email@site.net");
$mail->setHTML($message);

【讨论】:

  • 完成了这项工作。但我确实收到了超时错误,但电子邮件通过了。也许我应该更好地发送大量电子邮件。
  • 有趣。我觉得奇怪的是参数的顺序会导致问题。我已经使用/当前使用 PEAR:Mail,它对我来说效果很好。
【解决方案2】:

您确定 $row['email'] 是正确的列吗?

该错误似乎向我表明该函数正在接收的收件人列表是可疑的。

【讨论】:

    【解决方案3】:

    您使用的这个 htmlMimeMail 类是什么?你自己写的吗?

    这是一个不错的 PHP 邮件发送库:SwiftMailer

    至于以前能用,现在不能用的原因,可能是邮件服务器配置发生了变化。是你的邮件服务器吗?还是您的 ISP 的?我怀疑它由于某些垃圾邮件预防机制而改变了其行为。它可能会拒绝 SMTP RCPT 收件人,因为,例如,您尚未使用某些方式(如 SMTP 之前的 POP,或经过身份验证的 SMTP)首先登录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-28
      • 2013-06-02
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 2010-10-18
      • 1970-01-01
      • 2013-12-22
      相关资源
      最近更新 更多