尝试通过从数据库中提取电子邮件ID来发送超过2000封邮件,实际上已成功发送240封邮件,之后我收到了类似的错误
码
$mail->addAttachment('images/attach.gif');
$mysql = mysql_connect('localhost', 'username', 'password');
mysql_select_db('db_name', $mysql);
$result1 = mysql_query("SELECT first_name, email_id FROM email WHERE status = '0'", $mysql);
$body = file_get_contents('contents.php');
while ($row1 = mysql_fetch_array($result1)) {
$mail->AltBody = 'alt body text here';
$mail->msgHTML($body);
$mail->addAddress($row1['email_id'], $row1['first_name']);
if (!$mail->send())
{
echo "Mailer Error (" . str_replace("@", "@", $row1["email_id"]) . ') ' . $mail->ErrorInfo . '<br />';
break; //Abandon sending
} else
{
echo "Message sent to :" . $row1['first_name'] . ' (' . str_replace("@", "@", $row1['email_id']) . ')<br />';
}
// Clear all addresses and attachments for next loop
$mail->clearAddresses();
$mail->clearAttachments();
}
在240多封邮件发送后我得到了这种错误,我是phpmailer的新手请告诉我是什么问题以及如何解决这个问题,这个bug
错误
Mailer Error (***email***) The following From address failed: test@trbu.in : MAIL FROM command failed,503,sender already given
Mailer Error (***email***) The following From address failed: test@trbu.in : MAIL FROM command failed,503,sender already given
Mailer Error (***email***) SMTP Error: data not accepted.
Mailer Error (***email***) The following From address failed: test@trbu.in : MAIL FROM command failed,503,sender already given
Mailer Error (***email***) The following From address failed: test@trbu.in : MAIL FROM command failed,503,sender already given
...
...
...
答案 0 :(得分:1)
确保您使用latest PHPMailer。 msgHTML()
也设置AltBody
,因此如果您需要自定义AltBody
,请在调用msgHTML
后设置。{/ p>
MAIL FROM
错误表明您可能无法完成之前的消息,这可能是由于格式错误的内容或单个会话期间的消息计数限制造成的。如果您使用$mail->SMTPDebug = 2;
启用调试,则可以看到更多对话。
尝试设置$mail->SMTPKeepAlive = false;
以使其单独发送每条消息(速度较慢但更可靠),因为这可能是因为您尝试在单个连接中发送的邮件数超过主机允许的数量。您可以关闭发送循环并每200条消息重新打开SMTP连接以避免此问题。