【发布时间】:2023-03-30 08:14:02
【问题描述】:
我正在使用 cakephp 2.x 并使用电子邮件组件发送电子邮件。
我正在尝试在标题处添加 List-Unsubscribe。
$this->Email->headers = [
'List-Unsubscribe'=>'<mailto:'.$email_from.'?subject=Remove from Mailing List>, <'.$SITEURL.'unsubscribe?em='.$email_to.'>',
'List-Unsubscribe-Post'=>'List-Unsubscribe=One-Click'
];
现在在电子邮件源中,它显示在 X-header 中。
X-List-Unsubscribe: <mailto:clients@example.com?subject=Remove from Mailing List>, <http://example.com/unsubscribe?em=xyz@example.com>
X-List-Unsubscribe-Post: List-Unsubscribe=One-Click
但它没有显示带有 From 的取消订阅链接。
我需要在邮件标题中列出取消订阅以避免垃圾邮件。
当我尝试使用 $this->Email->additionalParams 时,它没有在电子邮件标题中显示 List-Unsubscribe。
这是我正在使用的代码
$send_from = $email_from_name . "<" . $email_from . ">";
$this->Email->sendAs = 'both'; // text / html / both
$this->Email->from = $send_from;
$this->Email->replyTo = $email_from;
$this->Email->return = $email_from;
$this->Email->to = $email_to;
$this->Email->delivery = 'smtp';
$this->Email->smtpOptions = ['host'=>$imap_server,'port'=>587,'username'=>$email,'password'=>$password];
$this->Email->subject = $subject;
$this->Email->headers = [
'List-Unsubscribe'=>'<mailto:'.$email_from.'?subject=Remove from Mailing List>, <'.SITEURL.'unsubscribe?em='.$email_to.'>',
'List-Unsubscribe-Post'=>'List-Unsubscribe=One-Click' ];
$this->Email->textMessage = $this->_html_to_text($content);
//$this->Email->delivery = 'debug';
$this->Email->send($content);
【问题讨论】: