letter_opener is one of the most useful gems out there for a rails developer. The configuration is pretty much easy and straightforward. But yet I stumbled upon a situation where it stopped working.

All the setup instructions were in order, but still, for some reason, the emails were not being displayed in a browser window but instead was being processed inline in the command-line or the terminal.

Google and StackOverflow were not helping, and the Github issue tracker of the gem was also not giving any pointers to this particular issue that I was facing.

Breakthrough.!

All the while, I was trying SomeMailer.notify.deliver. I decided to try .deliver! instead of .deliver and to my surprise letter_opener thew an error.

ArgumentError: SMTP From address may not be blank

That gave me a clue that I wanted.! My rails application did not have a default from for the action_mailer config. Adding a default from address to the action mailer like the below helped solve my issue.

config.action_mailer.default_options  = {
  from:  "no-reply <hi@til.codes>"
}

While it was surprising as to why there was no error or any indication that letter_opener was not processing the emails in the browser, it made complete sense when the bang version of the deliver method was used, which forced the error on you instead of failing silently and not trying to crash the app.

Hope this helps someone.!!