Mail delivery method in Rails 3
Rails 3 allows you to specify a custom mail delivery method in addition to the default options smtp, sendmail, test and file. You can do this by specifying the class name of your mail delivery handler in the config file like this:
And the interface your class needs to implement is:
How does this work?
Say you have a mailer class for sending out a welcome email:
When you try to deliver a welcome email, the Mail object constructed in the “welcome” method is sent to the deliver! method of your delivery class.
In your deliver! method you will then have full access to the mail object:
Why is this useful?
Consider a rails application like Twitter where different notification emails go out when people start following each other, send direct messages to each other, etc. Testing these emails by writing mailer tests is good. But it will also be…
View original post 81 more words