1
votes

I'm trying to setup the "List-Unsubscribe" header in Amazon AWS SES API using the sendEmail function in PHP. I've reviewed Amazon's documentation and many other posts here but haven't found anything that works yet. This is what I'm currently using:

$client->sendEmail(array(
   // all the main stuff like 'source', 'message', 'body', etc
  'List-Unsubscribe' => '<http://unsubscribe.link>',
));

... where http://unsubscribe.link is my unsubscribe URL.

Any suggestions?

2

2 Answers

6
votes

You'll need to use sendRawEmail instead of sendEmail in order to construct the raw message and add the List-Unsubscribe header to it.

TIP: It's better to use mailto-links instead of http-links as in List-Unsubscribe: <mailto:[email protected]> since not all mail clients support http unsubscribe links.

1
votes

Since late 2019 there is "SES v2", so the the method name is sendEmail, but the advice is essentially the same. There is a rawEmail option within sendEmail that you need to use to be able to set your own headers.