Skip to main content

Action Mailer: All mail comes from MAILER DAEMON

·122 words·1 min· ·
General RubyOnRails Features Ruby
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

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 <no-reply@example.com>">
    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.

Related

Ultimate List of Ruby Resources
·214 words·2 mins
General Web Development RubyOnRails Features Lists Ruby
Installing RMagick Ruby Gem on Mac OS X 10.4.9
·254 words·2 mins
General RubyOnRails Features Mac OS X Ruby
Rails production server setup and deployment on Ubuntu/Debian
·1516 words·8 mins
General RubyOnRails Features Linux Ubuntu