Add use of replaceCustomHeader in mailing list example, see #2981

This commit is contained in:
Marcus Bointon 2023-11-23 11:59:21 +01:00
parent 718eebd676
commit dd16b7d95b
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
1 changed files with 6 additions and 1 deletions

View File

@ -28,7 +28,7 @@ $mail->Username = 'yourname@example.com';
$mail->Password = 'yourpassword';
$mail->setFrom('list@example.com', 'List manager');
$mail->addReplyTo('list@example.com', 'List manager');
$mail->addCustomHeader('List-Unsubscribe', '<mailto:unsubscribes@example.com>, <https://www.example.com/unsubscribe.php>');
$mail->Subject = 'PHPMailer Simple database mailing list test';
//Same body for all messages, so set this before the sending loop
@ -55,6 +55,11 @@ foreach ($result as $row) {
//Assumes the image data is stored in the DB
$mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
}
$mail->replaceCustomHeader(
'List-Unsubscribe',
'<mailto:unsubscribes@example.com>, <https://www.example.com/unsubscribe.php?email=' .
rawurlencode($row['email']).'>'
);
try {
$mail->send();