Search code examples
ruby-on-railsrubyemailsmtpemail-headers

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.


Solution

  • The syntax for specifying headers is as follows:

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

    Looked at ActionMailer::Base documentation.