Once the ActionMailer base class was all patched up, I was able to add both the envelope sender and the message sender headers to outgoing messages. For test purposes I used the following simple test method:
def test(mail_to, mail_from)
subject “My simple rails mail”
recipients mail_to
from mail_from
sent_on Time.now
sender ” Accounts <accounts@mydomain.com>” #envelope and message header for SPF check
end
In addition, engine yard added an spf record to allow our messages to pass spf authentication checks:
“v=spf1 include72emailsrvr.com include72_spf.ey01.engineyard.com ~all”
Unfortunately, the messages I was sending myself as tests, once delivered, did not include the message sender header. Checking the production log confirmed that messages leaving our application included the message header.
After some troubleshooting, I discovered that the exim servers were stripping off the message sender header, as the message was being sent out This was because exim doesn’t allow non-local users to set the header (at least this seems to be a hard rule according to the documentation I’ve read). So as a workaround, we’re using another smtp provider that allows us to authenticate in, and then send mail. This is working great.
Ie. In the ActionMailer configuration:
ActionMailer::Base.smtp_settings = {
:domain => “yourdomain.com”,
:perform_deliveries => true,
:address => ‘smtp.yoursmtpserver.com’,
:port => 587,
:authentication => :login,
:user_name => “mailuser@yoursmtpserver.com” ,
:password => yourpassword
}