Trap rails from sending mail via SMTP
Nov 16, 2007
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,
}
Hi, I'm Glenn! 👋 I've spent most of my career working with or at startups. I'm currently the Director of Product @ Ockam where I'm helping developers build applications and systems that are secure-by-design. It's time we started securely connecting apps, not networks.
Previously I led the Terraform product team @ HashiCorp, where we launched Terraform Cloud and set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.
Previously I led the Terraform product team @ HashiCorp, where we launched Terraform Cloud and set the stage for a successful IPO. Prior to that I was part of the Startup Team @ AWS, and earlier still an early employee @ Heroku. I've also invested in a couple of dozen early stage startups.