Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How add List-Unsubscribe header to native mail() function of PHP

i've tested my spamscore on https://www.mail-tester.com/. It was good, but as an aprovement it suggested :

Your message does not contain a List-Unsubscribe header The List-Unsubscribe header is required if you send mass emails, it enables the user to easily unsubscribe from your mailing list.

How do I add this to a native mail(); function of PHP. Or is it even possible this way? (I cannot find one single simple example on the www).

like image 371
bwhendrickx Avatar asked Oct 21 '25 12:10

bwhendrickx


1 Answers

You can add additional headers with the mail() function.

$headers = [
    'From: [email protected]',
    'List-Unsubscribe: <mailto:[email protected]?subject=unsubscribe>'
];

$body = 'I am the newsletter content.';

mail('[email protected]', 'Subject of newsletter', $body, implode("\r\n", $headers));
like image 67
Markus Zeller Avatar answered Oct 24 '25 04:10

Markus Zeller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!