This project is archived and is in readonly mode.

#2853 ✓hold
Jean Vincent

ActionMailer: cannot set From header with smtp

Reported by Jean Vincent | June 29th, 2009 @ 04:07 PM | in 3.0.2

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.

Comments and changes to this ticket

  • Jean Vincent

    Jean Vincent June 29th, 2009 @ 04:22 PM

    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']
    
  • Jean Vincent

    Jean Vincent June 29th, 2009 @ 05:44 PM

    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.

  • Yehuda Katz (wycats)

    Yehuda Katz (wycats) July 2nd, 2009 @ 01:05 AM

    • 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 :)

  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2
    • Importance changed from “” to “”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages