我正在使用phpmailer发送电子邮件.
当我添加列表 - 取消订阅时,电子邮件将被发送到除gmail之外的所有帐户.它只是被丢弃,它不会进入垃圾邮件,它只是永远不会到达Gmail帐户.当我删除list-unsubscribe时,它会成功发送到gmail帐户.
这是我正在使用的列表取消订阅:
List-Unsubscribe:<http://keepity.com>,<mailto:admin@keepity.com>
Run Code Online (Sandbox Code Playgroud)
这就是它在phpmailer中的调用方式:
$mail->AddCustomHeader("List-Unsubscribe:<http://keepity.com>,<mailto:admin@keepity.com>");
Run Code Online (Sandbox Code Playgroud)
这是调用phpmailer的完整函数.如果我注释掉列表 - 取消订阅,那么邮件将被发送到gmail帐户,否则它永远不会到达.有谁知道为什么不交付?
static function phpmailer_sendmail($mail,$from,$fromAlias,$to,$replyTo,$replyToAlias,$subject,$html,$text) {
require_once (JPATH_COMPONENT.DS.'PHPMailer-master/class.phpmailer.php');
$mail = new PHPMailer(true); // by setting TRUE you enable exceptions
$mail->IsSMTP(true); // SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->Mailer = "smtp";
$mail->Host= "xyz"; // Amazon SES
$mail->Port = 465; // SMTP Port
$mail->Username = "xyz"; // SMTP Username
$mail->Password = "xyz"; // SMTP Password
$mail->ClearAllRecipients();
$mail->ClearAddresses();
$mail->ClearCCs();
$mail->ClearBCCs();
$mail->ClearReplyTos();
$mail->ClearAttachments();
$mail->ClearCustomHeaders();
$mail->SetFrom($from, $fromAlias);
$mail->AddReplyTo($replyTo,$replyToAlias);
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->Body = $html;
$mail->AltBody = $text;
$address = $to;
$addressAlias = $to;
$mail->AddAddress($address, $addressAlias);
$mail->AddCustomHeader("List-Unsubscribe:<http://keepity.com>,<mailto:admin@keepity.com>");
$mail->Send();
}
Run Code Online (Sandbox Code Playgroud)
小智 6
函数addCustomHeader获取2个参数,unscribe值格式应该是
<email_to_unscribe@email.com>, <http://url_to_unscribe.com>
Run Code Online (Sandbox Code Playgroud)
这是一个如何调用它的示例:
$mail->addCustomHeader("List-Unsubscribe",'<admin@keepity.com>, <http://keepity.com/?email='.$address.'>');
Run Code Online (Sandbox Code Playgroud)
小智 5
我知道这是旧的,但它在谷歌搜索“列表-取消订阅”时排名很好,并且提供的建议不太正确。
PHPmailer addCustomHeader 只接受一个参数。双引号像这样包裹整个标题。
$mail->AddCustomHeader("List-Unsubscribe: <mailto:info@example.com?subject=Unsubscribe>, <http://example.com/unsubscribe.php?mailid=1234>");
Run Code Online (Sandbox Code Playgroud)
List-Unsubscribe 需要 2 个参数,一个 mailto: 和一个可以设置为自动取消订阅电子邮件的 URL。当然,您也可以动态生成 mailid(或任何您调用的 GET var)。
| 归档时间: |
|
| 查看次数: |
10403 次 |
| 最近记录: |