Discovering Tools: Letter Opener
Welcome back to discovering tools, a series to discuss tools that make us, developers, productive and happy! Have ever had difficulties on debugging email message? Well, not anymore. We have leter opener gem for our Rails project. Letter opener is a gem that lets you preview your email in your web browser instead of sending it. You do not need a SMTP server anymore for your development environment! No longer cry over that accidentally sended email.
How to Use
You only need to three simple steps to use letter opener. First, at letter opener into your gemfile.
You only need letter opener for development, so, put it on the development group. Second, run standard bundle install on our rails project.
Lastly, set the email delivery method on config/environment/development.rb
Finished, now, you can easily debug your email from web browser. The email html file will be stored in tmp/letter_opener
directory.
Example Usage
Suppose that you have this mailer code.
And this mailer view on views/test_mailer/test.html.erb
. The content is taken from here. Then, go to rails console and run this command.
Here are the result.
Simple and clean. Letter opener really help us to debug our email easily and elegantly. Try it and feel the production and mood boost while developing great apps. :D. See you on the next episode of discovering tools.