sendgrid/sendgrid-php — pull request #44 by axiac (2013-09-22 19:01:15+00:00)
Title: added RFC 822 message headers

In our projects we need to add some message headers to the emails we send. "List-Unsubscribe" is one of them but also several extension headers ("X-") are in the list.

On a first glance, we thought the SendGrid PHP library provides the addHeader() method for this purpose but when we tested we couldn't find the headers in the received email.

After a closer inspection of the library code we discovered that this method and its relatives are used to prepare values that are sent in the 'x-smtpapi' parameter (see http://sendgrid.com/docs/API_Reference/Web_API/mail.html). It contains meta information that is used by SendGrid to prepare the email for sending and have nothing to do with the message headers; the substitutions, categories, filters go here.

Because the library doesn't provide any method to set values to be sent in the 'headers' parameter (they become message headers in the final message) we added them in this commit.