Rails, ActionMailer and a no-auth relay

07 Apr 2007

If you're using ActionMailer to send email from a Rails app and you're using a mail relay that doesn't require authentication (e.g., it's on a private subnet), here's how to specify that in your environment.rb file:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address  => "10.12.34.56",
  :port  => 25, 
  :domain  => 'my.host.name'
} 

You can just leave off the :username and :authentication parameters - setting them to "none" or blank or whatever won't have the same effect.