Dummy/Fake SMTP/Mail Trap for Development Purposes

This post started out as a question on StackOverflow.com (found here). I have moved over to Linux Mint 10 for all of my Ruby and Ruby on Rails application development. I have found this flavour of Linux to be the most pleasant for my purposes. But I ran into a bit of a problem when I first moved over form Windows.

Issue: On windows I had more than one option when it came to a dummy/fake SMTP/Mail trap which I could use to catch and examine the emails generated and sent out by the applications on which I was working. Extremely useful when testing account registration and email activation 🙂 But on Linux all I found were posts about setting up a full blown SMTP server and then connecting a mail client to it and pulling the emails locally. PUKE, GAG,VOMIT way too much work for me and I am really not interested in becoming a professional mail server administrator.

Solution: After millions of hours searching for a decent solution I ram across a Ruby Gem called MailTrap, oh my saviour, I can’t even begin to tell you how much I love this GEM, it makes my life so much easier.

[sudo] gem install mailtrap

Then don’t forget to setup your development environment file with the following entries

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:domain => “mydomain.net”,
:address => “localhost”,
:port => 2525,
config.action_mailer.default_url_options = { :host => ‘localhost:2525’ }

Then simply run the gem application in a terminal window and you will see each of the mail messages as they come in or you can view them in the log file that is created.

mailtrap run

Published by

Tim Clark

Experienced Business Owner, Chief Information Officer, Vice President, Chief Software Architect, Application Architect, Project Manager, Software Developer, Senior Web Developer, Graphic Designer & 3D Modeler, University Instructor, University Program Chair, Academic Director. Specialties: Ruby, Ruby on Rails, JavaScript, JQuery, AJAX, Node.js, React.js, Angular.js, MySQL, PostgreSQL, MongoDB, SQL Server, Responsive Design, HTML5, XHTML, CSS3, C#, ASP.net, Project Management, System Design/Architecture, Web Design, Web Development, Adobe CS6 (Photoshop, Illustrator)

One thought on “Dummy/Fake SMTP/Mail Trap for Development Purposes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s