[英]Send multiples emails using multiples username and password with php mailer?
好吧,我得到了这段代码,它可以正常工作,但是我需要设置每个循环的PHPMailer,idk(如果很好),但是如果我没有设置每个循环的话,那么从不更改始终是我设置的第一个,请看:
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'];
...
它可以工作,但是我在每个循环中都设置PHPMailer,但是如果我这样做:
$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'];
...
它会起作用,但是from不会改变每个循环。
我没有适合您的解决方案,但想与我分享PHPMailer的经验:即使电子邮件相同但收件人不同,我也必须为发送的每个邮件创建一个全新的对象才能获得所需的结果。 。
很难说。 错误报告是否设置为显示所有错误? phpMailer有什么问题吗? 这不太可能,但是我刚刚看到一个类似的问题,正在运行的对象循环会污染日志并阻止脚本正确执行。
我希望这有帮助。 请让我知道您的发现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.