While developing an App, at some point it become necessary to test out emails sent for users. Maybe for testing the Email template, maybe for checking if emails were being sent out properly. Or maybe any other purpose.

Testing emails can be a severe pain in the ass. It takes time to deliver, sent to spam or just doesn't reach out in your inbox. Most of the time, you wouldn't have mailer in your development system to send outgoing mail! (Specially in Linux/Windows)

Here comes MailCatcher to make these things breeze. MailCatcher is a Ruby gem. It gives you local email server and a nice WebUI to check emails.

How to use MailCatcher

First we need to install it. Installing MailCatcher is very simple, just like any standard Ruby gem.

gem install mailcatcher

Now, run the server.

mailcatcher

It'll start a daemon SMTP server on port 1025 and the WebUI on port 1080. Simply visiting the URL http://127.0.0.1:1080 will take you to the WebUI.

Now configure your app to sent email to MailCatcher.

SMTP Host: localhost
SMTP Port: 1025

If you're running Rails app, just place this in your development.rb file.

config.action_mailer.smtp_settings = {address: 'localhost', port: 1025}

If you're running Laravel, set those values in your .env file. Username and Password won't be required. For WordPress, use WP-SMTP plugin.

And.. done, any mails sent out from your app to any address, will be appear in your MailCatcher WebUI.

What do you use to interpret mails locally? Do you've any other preference? Please let me know in the comments. :)




What's on your mind?


446 Comments