phpMailer - 如何删除收件人 [英] phpMailer - How do you Remove Recipients
问题描述
这个主题有很多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;
这样我只需运行这四行代码,然后一次又一次地发送邮件,需要多次。 主题
, IsHTML
和正文
字段很容易更改,所以我遇到的问题是在 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屋!