简体   繁体   English

组电子邮件使用php mailer显示错误

[英]Group email is shows error using php mailer

Actually I want to send a group mail so I have taken the mail id's from db and stored in the variable but when I try to send mail using delimeter as ',' , it shows invalid email id 实际上,我想发送组邮件,因此我已从db中获取了邮件ID,并将其存储在变量中,但是当我尝试使用delimeter作为','发送邮件时,它显示了无效的电子邮件ID

Below code to Take mail id's from db: 下面的代码从数据库获取邮件ID:

while ($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) {


      $word = $row['Email'];

      $GetData = $GetData.$word.',';

}

Now $GetData =example1@gmail.com,example2@gmail.com 现在$GetData =example1@gmail.com,example2@gmail.com

php mailer PHP邮件

$mail->addAddress$GetData ,user ); 

When I add the same into add address it is not working 当我将其添加到添加地址时,它不起作用

Message could not be sent.Mailer Error: Invalid address: (to):example1@gmail.com,example2@gmail.com 无法发送邮件。邮件程序错误:地址无效:(收件人):example1 @ gmail.com,example2 @ gmail.com

Note: if single id then it is sending successfully , so seems like issue with my side so need assistance on this. 注意:如果是单个ID,则说明发送成功,因此我这边似乎有问题,因此需要帮助。

You need to use addAddress for each recipient, you are kind of mixing the old headers style with the new mail object.. 您需要为每个收件人使用addAddress,您需要将旧的标头样式与新的邮件对象混合使用。

while ($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) {

  $mail->addAddress($row['Email'] , '');

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM