I use Sendgrid to send email to the mailing list using the X-SMTPAPI header to specify multiple recipients. From the sending documentation . Headers should be wrapped so that the line length does not exceed 72.
I use ActionMailer to send emails and set the X-SMTPAPI header using the method headers. To keep lines less than 72 characters, I tried replacing each comma with a comma + new line + space. For instance,
headers["X-SMTPAPI"] = {
:to => ['user1@example.com','user2@example.com','user3@example.com','user4@example.com','user5@example.com','user6@example.com']
}.to_json.gsub(',',",\n ")
Instead of getting newlines in my header, I get the following (from the log file)
X-SMTPAPI: {"to":["user1@example.com",=0A "user2@example.com",=0A "user3@example.com",=0A "user4@example.com",=0A "user5@example.com",=0A "user6@example.com"]}
Note that the \ n characters are replaced with =0A. This sequence is rejected by the Sendgrid server as invalid.
Any ideas what I can do to get the correct newlines in the header?
Edit: I tried adding “puts headers” to see what is given in the headers. Then I found
Date: Sat, 13 Apr 2013 18:21:36 -0400
Message-ID: <5169da701cd26_5343fe1776afc50749b4@saunders.mail>
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
X-SMTPAPI: {"to":["user1@example.com",=0A "user2@example.com",=0A
"user3@example.com",=0A "user4@example.com",=0A "user5@example.com",=0A
"user6@example.com"]}
Please note that the new lines that I am adding still display as "= 0A". But it looks like packaging is being added on its own. Is this automatic wrapping and sufficient to make my title bar length exceed the requirements?