Testing emails was always a pain for me and my designer friend. my designer friend keep asking me how can I test emails in development mode in ruby on rails without integrating sendgrid or critsend, so this post dedicated to him only. I was always looking for a solution for the same, Specially after working on emaillist.io (A group emailing service.) and today I got one. MailCatcher.
Pretty easy to use and configure. Add in the gem file, add some code in config/development.rb and start the mailcatcher daemon. Lets do it one by one.
Add this in your gem file.
Run bundler and in your development configuration file config/development.rb, set the following Action Mailer settings:
and start your rails app and mailcatcher daemon from terminal just by typing mailcatcher
Now open http://127.0.0.1:1080 in your browser and you can see a virtual inbox. Try triggering some email from your application and you will emails coming in your virtual inbox. Another awesome feature of MailCatcher is that you can view both the HTML and plain text versions of emails, download attachments and also run some analysis of your email. I just loved it. I hope you will too. ;)
Make sure before going to production you test it in real scenario’s. ** Sample Output**