$phpMailer = New PHPMailer();
$phpMailer->isSMTP();
$phpMailer->SMTPKeepAlive = true;
for ( ... ) {
// Send your emails right away
[ ... ]
}
$phpMailer->SmtpClose();
嗨,我这里有一个 KeepAlive SMTP 的示例代码,但我的问题是我向用户发送包含不同内容的电子邮件。所以每个用户都有 1 个内容。
我可以这样做吗:
for ( ... ) {
$phpMailer->addAddress($user['email'], $user['name']);
$phpMailer->Subject = $user['subject'];
$phpMailer->Body = $user['body'];
$phpMailer->Send()
}
->addAddress 会在每次循环中增加我的收件人吗?还是会在提交 ->send(( 后清理旧收件人?
在 addAddress 函数之前调用 clearAddresses(( 。它在收件人之前被清除。
$phpmailer->ClearAddresses();
$phpMailer->addAddress($user['email'], $user['name']);