Skip to content
Support for multiple SMTP servers in ActionMailer
Find file
Latest commit cb66592 Jeff Jolma a few fixes:
1. rescue any Exception (e.g. TimeoutException) when trying the
   primary mailer
2. if no :retry is passed in to with_settings then use :default.  This
   requires less typing for an app with many call sites
3. fix tests

Note: tests require mocha



Multiple SMTP servers for ActionMailer.


  ProjectMailer.with_settings(:internal) do |mailer|

You can also specify servers to use in the event that the initially specified
server fails:

  ProjectMailer.with_settings(:internal, :retry => [:backup, :default]) do |mailer|


Create a YAML file in your config directory named "mail_servers.yml" Put
your mail settings in there like so (see mail_servers.yaml in this plugin's 
test directory for a better example):

  |  address:
  |  port: 25
  |  domain:
  |  user_name: test_user
  |  password: test_password
  |  address:
  |  port: 25
  |  domain:
  |  user_name: test_user
  |  password: test_password
The plugin will look for a server named "default" to use by default. Make sure
it exists.

ActionMailer::Base (and all of its subclasses, ie, your mailers) will use this
server by default.


* Per-mailer settings (non-global)
* ActionMailer::Base#with_settings shouldn't modify SMTP settings for other
  mailers besides the one that called it.

Copyright (c) 2008 Animoto Productions, released under the MIT license
Something went wrong with that request. Please try again.