PHPMailer AddAddress()
我不知道应该如何为 AddAddress PHPMailer 函数格式化数据;我需要将电子邮件发送给多个收件人,所以我尝试了
I don't know how the data should be formatted for AddAddress PHPMailer function; I need the email to be sent to multiple recipients so I tried
$to = "me@domain.com,you@domain.net,she@domain.it";
$obj->AddAddress($to);
但没有成功.任何帮助将不胜感激.
but with no success. Any help will be appreciated.
推荐答案
您需要为每个要发送到的 E-Mail 地址调用一次 AddAddress
函数.此函数只有两个参数:recipient_email_address
和 recipient_name
.收件人姓名是可选的,如果不存在则不会使用.
You need to call the AddAddress
function once for each E-Mail address you want to send to. There are only two arguments for this function: recipient_email_address
and recipient_name
. The recipient name is optional and will not be used if not present.
$mailer->AddAddress('recipient1@domain.com', 'First Name');
$mailer->AddAddress('recipient2@domain.com', 'Second Name');
$mailer->AddAddress('recipient3@domain.com', 'Third Name');
您可以使用数组来存储收件人,然后使用 for
循环.我希望它有所帮助.
You could use an array to store the recipients and then use a for
loop. I hope it helps.
相关文章