user393964
user393964

Reputation:

Ruby custom email headers

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.

Upvotes: 1

Views: 941

Answers (2)

Peter H. Boling
Peter H. Boling

Reputation: 584

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

headers['X-SMTPAPI'] = '{"thing": "SomeEmail"}'

Upvotes: 0

Simon Perepelitsa
Simon Perepelitsa

Reputation: 20639

The syntax for specifying headers is as follows:

headers({'X-No-Spam' => 'True', 'In-Reply-To' => '[email protected]'})

Looked at ActionMailer::Base documentation.

Upvotes: 2

Related Questions