Well i got this code, it works but i need to set every loop the PHPMailer, idk if it's good but if i don't set it every loop the from don't change always come the first that i set, look:
foreach($this->users as $v)
{
$this->phpmailer = new PHPMailer();
$this->phpmailer->IsSMTP();
$this->phpmailer->SMTPAuth = true;
$this->phpmailer->SMTPSecure = 'ssl';
$this->phpmailer->Host = 'smtp.gmail.com';
$this->phpmailer->Port = 465;
$this->phpmailer->ClearAllRecipients();
$this->phpmailer->AddAddress($v['email']);
$this->phpmailer->Username = $v['email_user'];
$this->phpmailer->Password = $v['email_pass'];
$this->phpmailer->From = $v['email_user'];
$this->phpmailer->FromName = $v['email_name'];
...
it works but i'm setting PHPMailer every loop but if i do:
$this->phpmailer = new PHPMailer();
$this->phpmailer->IsSMTP();
$this->phpmailer->SMTPAuth = true;
$this->phpmailer->SMTPSecure = 'ssl';
$this->phpmailer->Host = 'smtp.gmail.com';
$this->phpmailer->Port = 465;
foreach($this->users as $v)
{
$this->phpmailer->ClearAllRecipients();
$this->phpmailer->AddAddress($v['email']);
$this->phpmailer->Username = $v['email_user'];
$this->phpmailer->Password = $v['email_pass'];
$this->phpmailer->From = $v['email_user'];
$this->phpmailer->FromName = $v['email_name'];
...
it will work but the from doesn't change every loop.
我没有适合您的解决方案,但想与我分享PHPMailer的经验:即使电子邮件相同但收件人不同,我也必须为发送的每个邮件创建一个全新的对象才能获得所需的结果。 。
Hard to say. Is error reporting set to show all errors? Is anything failing from phpMailer? And this is unlikely, but I just saw a similar issue where running object loops polluted a log and preventing the script from executing correctly.
I hope this helps. Please let me know what you find.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.