1

I'm trying to send an email with custom headers but for some reason they just don't get through.

When I call my mailing method in the console, my custom parameter is actually listed:

<X-SMTPAPI: {"messageid" : "nomnom"}>

This is what I'm doing in my code:

headers["X-SMTPAPI"] = "{\"messageid\" : \"nomnom\"}"
mail(:to => @user.email, :subject => "Confirmation"  )

Any idea what I'm doing wrong?

EDIT: The problem seems to be with using X-SMTPAPIas key. Using something else does work.

2 Answers2

2

The syntax for specifying headers is as follows:

headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'})

Looked at ActionMailer::Base documentation.

Simon Perepelitsa
  • 20,350
  • 8
  • 55
  • 74
  • But where do I specify `X-SMTPAPI` than? –  Dec 14 '11 at 11:22
  • @Sled, look at the above code. @Semyon is setting two headers, `X-No-Spam` and `In-Reply-To`; you just need to substitute those two with your example. – d11wtq Dec 14 '11 at 11:56
  • Looks like you can also do: `default "X-SMTPAPI" => "{\"messageid\" : \"nomnom\"}"`. – d11wtq Dec 14 '11 at 11:58
0

The Headers can only be set to perfectly valid JSON. This should work:

headers['X-SMTPAPI'] = '{"thing": "SomeEmail"}'
Peter H. Boling
  • 512
  • 5
  • 14