Why Letter opener gem doesn't open your letters

Last updated on December 20, 2021

Letteropener is a great gem for opening letters locally. It has one of the easiest configurations out of any gem. Up until now, it was working as intended when all of a sudden it just stopped working.

Earlier this week, I was developing a new feature for my client. I was almost done with it - I just needed to see how the final email would look like. Easy enough - letteropener to the rescue. But for some reason, I didn’t receive my emails as usual.

The usual helpers - Stack Overflow and Github Issues were of no use.

Debug, Debug, Debug 🔬

I had no idea that you can do ExampleMailer.deliver! instead of .deliver_later or .deliver.

This gave me the error

letter opener SMTP To address may not be blank

Finally - something to work with!

My query for my TO email was wrong 🤦‍♂️

I instantly realised what’s wrong - I didn’t define my query for my recipient in the correct way. LetterOpener was working as intended, it was my code that was wrong, but Rails didn’t let me know until I used .deliver!

Invite us to your inbox.

Articles, guides and interviews about web development and career progression.

Max 1-2x times per month.