Testing emails was always a pain for me and my designer friend. my designer friend keeps 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, Especially 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 mail catcher daemon. Let’s 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 mail catcher daemon from terminal just by typing mail catcher
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 email 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**