问题描述
我已经在 https://www.mail-tester.com/ 上测试了我的垃圾邮件评分。这很好,但作为一项建议,它建议:
您的消息不包含 List-Unsubscribe 标头 如果您发送大量电子邮件,则需要 List-Unsubscribe 标头,它 使用户可以轻松地退订您的邮件列表。
如何将其添加到 PHP 的本机 mail();
函数中。或者甚至有可能这样吗? (我在 www 上找不到一个简单的例子)。
解决方法
您可以使用 mail() 函数添加其他标题。
$headers = [
'From: thisisme@example.net','List-Unsubscribe: <mailto:thisisme@example.net?subject=unsubscribe>'
];
$body = 'I am the newsletter content.';
mail('recipent@example.net','Subject of newsletter',$body,implode("\r\n",$headers));