I am trying to add header to message sent via swift mailer.
$message = Swift_Message::newInstance($title)
->setFrom(array('[email protected]' => 'Name'))
->setTo(array($email => $email))
->setBody($content, 'text/html');
tried this, returns error
$message-> addTextHeader('List-Unsubscribe', $url_unsub);
This returns does nothing, but does not return error also
$headers = $message->getHeaders();
$headers->addTextHeader('List-Unsubscribe', $url_unsub);
$result = $mailer->send($message);
Any idea what to do?
First, change to:
$message->getHeaders()->addTextHeader('List-Unsubscribe', $url_unsub);
because you doesn't set/relate your $headers
to $message
after calling getHeaders()
.
Second. Check if $url_unsub
contains really proper format for header "List-Unsubscribe"
. Look e.g. here => http://www.list-unsubscribe.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With