Trap rails from sending mail via SMTP
Posted by glenn on Friday, November 16, 2007
Posted in email, testing, rubyonrails
Trap rails from sending mail via SMTP Matt Mower has released a handy little tool called Mailtrap. Basically what it does as act as a very simple SMTP server that accepts requests from ActionMailer, but writes them to file instead of emailing them on.
Installation is very straight forward:
sudo gem install -y mailtrap
And then start it up:
mailtrap start
Which will start the mailtrap app to listen on port 2525. Now all that is left to do is change the config in your rails app to connect to localhost:2525 in either /config/environment.rb or /config/environment/development.rb:
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:domain => "mydomain.net",
:address => "localhost",
:port => 2525,
}
Glenn Gillen is a ruby and ruby on rails developer with clients in London, New York, Los Angeles, and Australia. Ruby Pond specialise in social networking development, and social and online marketing. Contact Ruby Pond if you wish to discuss hiring Glenn or one of our other developers for your own project.
blog comments powered by Disqus