Hi -
I'm stuck on something 'simple' - custom mail header. Seems this should work but can't get it to come out correctly. Any help appreciated:
Hi -
I'm stuck on something 'simple' - custom mail header. Seems this should work but can't get it to come out correctly. Any help appreciated:
In your call to #mail:
mail(:to => 'test@sample.com',
:from => email,
:subject => "Message from the site",
:headers['X-SMTPAPI'] => "{\"category\" : \"Drip Email\"}"
)
you're passing a hash of headers to the #mail method, and one of your keys is :headers['X-SMTPAPI']. Ruby tries to execute this as calling the # method on the symbol :headers, which returns nil (under ActiveSupport).
This all happens before the #mail method gets a chance to see it; in other words, your method call looks like this:
mail(:to => 'test@sample.com',
:from => email,
:subject => "Message from the site",
nil => "{\"category\" : \"Drip Email\"}"
)
That's why you're seeing the {"category" : "Drip Email"} value appear in your email, but with an empty name for the header.
To set a header value, you can either specify it directly in the hash you pass to #mail:
mail(:to => 'test@sample.com',
:from => email,
:subject => "Message from the site",
'X-SMTPAPI' => "{\"category\" : \"Drip Email\"}"
)
or you can use the #headers method separately:
headers['X-SMTPAPI'] = "{\"category\" : \"Drip Email\"}"
mail(:to => 'test@sample.com',
:from => email,
:subject => "Message from the site"
)
Chris