devroom.io/drafts/2007-06-20-action-mailer-all-mail-comes-from-mailer-daemon.md
Ariejan de Vroom dbae98c4c0 Moar updates
2013-03-24 14:27:51 +01:00

1.0 KiB

title kind slug created_at tags
Action Mailer: All mail comes from MAILER DAEMON article action-mailer-all-mail-comes-from-mailer-daemon 2007-06-20
General
RubyOnRails
Features
Ruby

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:

class UserNotifier < ActionMailer::Base
  protected
    def setup_email(user)
      @recipients  = "#{user.email}"
      @from        = "My Application 
    end
end

May you spotted the problem already, but I didn't. All the mail sent came from "MAILER DAEMON".

From: 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.