Last updated

Action Mailer: All mail comes from MAILER DAEMON

Today I was trying to send mail from my Rails application through Action Mailer. This is quite simple, but I wanted to use a custom from-address. So, I create a setup_email method in my UserNotifier class that sets some defaults for every email sent out:

1class UserNotifier < ActionMailer::Base
2  protected
3    def setup_email(user)
4      @recipients  = "#{user.email}"
5      @from        = "My Application <no-reply@example.com>">
6    end
7end

May you spotted the problem already, but I didn’t. All the mail sent came from “MAILER DAEMON”.

1From: MAILER DAEMON

The problem was that @from didn’t contain a properly formated from-address. It is missing the closing >, and so my email server ignores it.

If you have this issue, double check the from address, and make sure it’s valid! Cheers.