Implementing List-Unsubscribe header(s) with swiftmailer (rfc2369, rfc6068, rfc8058, and friends)

772 Views Asked by At

Has anyone implemented the List-Unsubscribe & List-Unsubscribe-Post headers using swiftmailer ?

I know how to insert headers ...

$_headers = $message->getHeaders();
$_headers->addTextHeader( 'List-Unsubscribe', $list_unsubscribe );
if ( $has_dkim ) $_headers->addTextHeader( 'List-Unsubscribe-Post', 'List-Unsubscribe=One-Click' );

$list_unsubscribe variable may contain one <url> and/or one <mailto>

1st problem : Whatever the order of List-Unsubscribe and List-Unsubscribe-Post headers are set, they always appear in the wrong order (List-Unsubscribe-Post before List-Unsubscribe). I tried to change header ordering using method defineOrdering, but that did not work as intended. I even tried to hack the swiftmailer code to append those two new headers to the existing order list ... but did not work !

2nd problem : Would appreciate any hint on how to encode properly these two <url> & <mailto> using swiftmailer toolbox (i am also using the Decorator plugin).

Thank you for your answers.

1

There are 1 best solutions below

0
On

So, 1st problem is solved !

According to RFC 5322

... header fields are not guaranteed to be in a particular order.