Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActionMailer: cannot set From header with smtp

#2853

ActionMailer 2.3.2. When using Restful Authentication plugin.

In app/models/user_mailer.rb, setting @from = 'admin@example.com' fails to deliver the email.

Action Mailer sets variable 'sender' to ["admin@example.com"] line 677 in /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-2.3.2/lib/action_mailer/base.rb

Action Mailer sends to SMTP server:
MAIL FROM:["admin@example.com"]

SMTP server replies:
501 ["admin@example.com"]: missing or malformed local part

This can be fixed by changing line 677 in /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-2.3.2/lib/action_mailer/base.rb
from:
sender = (mail['return-path'] && mail['return-path'].spec) || mail.from
to:
sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']

However doing this does not enable one to set a complete email address such as 'Admin admin@example.com' because Net::SMTP adds <> to the email address, which might require a bigger fix.

Reported by Jean Vincent · June 29th, 2009 @ 04:07 PM

State: hold
Milestone: 3.0.2
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: none

Activity

  1. Jean Vincent
    Jean Vincent

    Sorry I failed to format properly the ticket (my first here).

    Action Mailer sends SMTP server:
    @@@ SMTP MAIL FROM:["admin@example.com"]

    
    SMTP server replies:
    @@@ SMTP
    501 <["admin@example.com"]>: missing or malformed local part
    

    This can be fixed by changing line 677 in /usr/local/lib/ruby/gems/1.9.1/gems/actionmailer-2.3.2/lib/action_mailer/base.rb from:
    @@@ Ruby sender = (mail['return-path'] && mail['return-path'].spec) || mail.from

    
    to:
    @@@ Ruby
    sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']
    

    June 29th, 2009 @ 04:22 PM

  2. Jean Vincent
    Jean Vincent

    I found that this is similar to #2340 action mailer can't deliver mail via smtp on ruby 1.9.1.

    This isn't obvious from the title. Action Mailer works if one does not set the from header with an email address.

    That said, one still cannot set a full (named) rfc2822 email address.

    June 29th, 2009 @ 05:44 PM

  3. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • Assigned user set to Yehuda Katz (wycats)
    • State changed from new to hold
    • Tag changed from 2.3.2, actionmailer, restful_authentication to 3.0, actionmailer, restful_authentication
    • Milestone cleared.

    This will be addressed when we rework ActionMailer for 3.0. In the meantime, if you'd like to submit a patch against 2.3 we'll gladly accept it :)

    July 2nd, 2009 @ 01:05 AM

  4. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to

    October 15th, 2010 @ 11:01 PM