如何不让 PHPmailer 发送带有多个“收件人"地址的电子邮件? [英] How to not make PHPmailer send an email with multiple 'to' addresses?

查看:60
本文介绍了如何不让 PHPmailer 发送带有多个“收件人"地址的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有一个表格,其中包含要发送的电子邮件.脚本作为 cron 作业定期运行,以从表中读取数据并通过 SMTP 服务器发送电子邮件.我在这里使用 PHPMailer 进行工作.该脚本运行循环发送电子邮件,直到表中的所有电子邮件都已发送.

I have a table in my database which contains emails to be sent. A script runs periodically as a cron job to read the data from table and dispatch the emails via the SMTP server. I am using PHPMailer for the work here. The script runs a loop for sending emails until all the emails in the table have been sent.

问题是大多数连续发送的电子邮件都有一个共同的主题.因此,当循环运行时,不知何故发送的所有电子邮件都有一个很长的收件人"列表.因此,基本上如果 5 个电子邮件条目(具有不同的 to 地址)具有相同的主题和相同的内容,那么它最终只会在收件人"中发送 1 个带有 5 个地址(每个电子邮件条目之一)的电子邮件场地.这会向列表中的其他人显示每个人的电子邮件地址.这是不可取的,电子邮件必须只发送给它所针对的那个人.

The problem is that most consecutive emails being sent have a common subject. So when the loop runs, somehow all the emails that get sent have a long 'to' list. So basically if 5 email entries (with different to addresses) have the same subject and same content, then it ends up sending only 1 email with 5 addresses (one of each email entry) in the 'to' field. This reveals the email address of every person to everyone else on the list. This is undesirable and the emails must be sent to only that one person for whom it is meant.

我不知道这里发生了什么.有什么建议吗?

I don't know what's at play here. Any suggestions?

推荐答案

你在做这样的事情吗?

$mailer = new PHPMailer();

while($row = fetch_from_db()) {
   $mailer->AddAddress($row['email']);
   $mailer->send();
}

如果是这样,你需要做一个

If so, you need to do a

$mailer->ClearAllRecipients()

在您发送每封电子邮件后,您会从一个新"To: 列表开始.

after you send each email, so you start out with a "fresh" To: list.

这篇关于如何不让 PHPmailer 发送带有多个“收件人"地址的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆