First post in a while.. hopefully that will be changing soon. Anyway.. Happy Friday everyone.
The other day I went to integrate rackspaces's email service with an application we have here at work. Very quickly I realized that I was having troubles using their secure connection parameters. The unsecured (port 25) worked fine, but we need to get the secure version working.
Long story short, the problem was due to the configuration of rackspaces email servers and the fact that they were not advertising TLS support. If you are not aware, ActionMailer is built off of the fantastic Mail gem, which relies on Net::STMP modules. When you go to send the mail the first thing that happens is a connection is made to the mail server and the capibiilites are returned by the HELO, or EHLO command. When STARTTLS is not advertised the code thinks that the capability is not there so it tries to send the email without TLS support and this is where my problem was. The rackspace servers were requiring it to deliver the message correctly.
According to the RFC's TLS support is not manadtory and there are valid security reasons as to why you would not advertise it, so rackspace is not doing anything wrong here. But since it is required I had to figure out a good way to force the issue. Shockingly there was no way to force ActionMailer to use TLS regardless of what the mail server says. There are settings to disable automatically checking for it, and ways to deal with the SSL context if need be, but no way to say.. Hey USE TLS!!!...
So the solution.. monkey patch the low level SMTP module.
There might be a better way to accomplish this, but this way worked for us. Below are the final action mailer settings used to connect securely with rackspace.
ActionMailer::Base.smtp_settings = {
:address => "secure.emailsrvr.com",
:port => 465,
:domain => "mydomain.com",
:user_name => "email@mydomain.com",
:password => "password",
:authentication => :login
}
As always, comments and feedback are greatly appreciated.
Comments