I would like to alter the Message-ID
header that is in the header portion of an email sent from a Ruby on Rails v3 application using ActionMailer.
I am using Sendmail on localhost for mail delivery.
Do I configure this in Sendmail or ActionMailer?
Where do I configure this (if it is ActionMailer): a file in config/
folder or a file in app/mailers/ folder?
I figured this out. The easiest way to do is to use the
default
method at the top of the mailer class file.Example:
However, I found this difficult to test, so I wrote a private method and used the
sent_at
time instead ofTime.now
:And I simply called that method before calling the
mail
method. This made it easy to pass asent_at
parameter from my test and verify a match inemail.encoded
.