phpMailer - 你如何删除收件人 [英] phpMailer - How do you Remove Recipients

查看:43
本文介绍了phpMailer - 你如何删除收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于这个主题有很多 StackOverflow 问题,但我找不到一个能够帮助解决我遇到的问题的问题.我正在编写的脚本向具有不同邮件内容的不同收件人发送多封电子邮件.

There are a lot of StackOverflow questions on this topic, but I couldn't find one that was able to help with the issue I'm having. The script that I'm writing sends out multiple emails to various recipients with different message contents.

我可以通过多次重新初始化 phpMailer 对象来使其工作,但我希望能够做的是一次创建对象,然后重新分配以下字段:

I can get this working by re-initializing the phpMailer object multiple times, but what I'd like to be able to do is create the object a single time, and then re-assign the following fields:

$mail->AddAddress($email);
$mail->Subject = $subject;
$mail->IsHTML(false);
$mail->Body = $message;

这样我就可以只运行这四行代码,然后根据需要一次又一次地发送邮件.SubjectIsHTMLBody 字段很容易更改,所以我遇到的问题是 AddAddress 功能.

That way I can just run those four lines of code and then send the mail out, again and again, as many times as necessary. The Subject, IsHTML, and Body fields are easily changed, so the problem I'm having is in the AddAddress function.

正如您可能猜到的,在我发送第一封电子邮件后,更改未来电子邮件的收件人将导致这些收件人叠加到当前收件人列表中.

As you can probably guess, after I send out the first email, changing recipients for future emails will result in those stacking onto the current list of recipients.

简单地说,如何删除与我的 $mail 对象关联的电子邮件地址,以便我可以在删除旧地址的同时每次分配它们?

To put it simply, how can I remove the email addresses associated with my $mail object so that I can assign them each time while removing the old addresses?

除了 AddAddress 之外,还有其他函数可以用来分配地址吗?

Is there another function besides AddAddress that I can use that will just assign the addresses?

推荐答案

您可以使用 clearAllRecipients()

$mailer->clearAllRecipients();//清除所有

这篇关于phpMailer - 你如何删除收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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