How To Test Rails ActiveMailer Emails In Your Development Environment

Posted by Weston Ganger

You definitely need to test your emails that you send in your app. Skipping them in development is not a good idea.

There are two methods for you to do this:

My personal favourite is the simple fake SMTP server with Python which just pipes the email through your log which is what I usually want.

# Create Init.d Startup Script to Start Fake SMTP Server on System Startup
sudo echo "python -m smtpd -n -c DebuggingServer localhost:25 > /dev/null 2>&1 &" > /etc/init.d/fake-smtp # replace /dev/null with a file if you want to keep your email logs.
sudo chmod +x /etc/init.d/fake-smtp
sudo update-rc.d fake-smtp defaults

# Start Script Right Away without Rebooting
sudo /etc/init.d/fake-smtp start

Or if you want to see your slick email in the browser with full html you can use the MailCatcher or letter_opener gems

Related External Links:

Article Topic:Software Development - Rails

Date:May 03, 2016

Recommended Posts



Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected