在PHP邮件程序中发送多个邮件 [英] Sending Multiple Mails In PHP Mailer
本文介绍了在PHP邮件程序中发送多个邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在写一个触发器,通过PHP邮件发送邮件。该代码的问题是它向单个收件人发送多个邮件。我甚至尝试使用函数singleTo
,但即使这似乎不起作用。
I have been writing a trigger that mails an email using PHP mailer. The problem with the code is that it is sending multiple mails to a single recipient. I even tried using the function singleTo
but even that didn't seem to work.
$mail = new PHPMailer();
for($i = 0; $i <= sizeof($emailid); $i++) {
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->SingleTo = true;
$mail->AddAddress($emailid[$i],$name[$i]);
$mail->Subject = 'Some Subject';
$mail->Body = "Some Body";
$mail->AltBody = "Some Body";
$errornumber[$i] = 1;
if(!$mail->Send()) {
$errorinfo[$i] = $mail->ErrorInfo;
$errornumber[$i] = 0;
}
}
推荐答案
我使用几乎相同的脚本,但我也设置了这个:
I am using almost same script, but I also set this:
while(...)
{
$mail = new PHPMailer(); //reset class instance to new one
.....
$mail->From = $fromAddress;
$mail->FromName = $fromAddress;
$mail->AddAddress($toAdress);
....
}
.... - 你有
.... - same code as you have
这篇关于在PHP邮件程序中发送多个邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文