This project is archived and is in readonly mode.

#3078 ✓duplicate
Travis Sinnott

ActionMailer 2.3.3 broke display name support in from address when using SMTP

Reported by Travis Sinnott | August 19th, 2009 @ 05:59 PM

A change made to ActionMailer in 2.3.3 to better support Ruby 1.9 seems to have broken support for display names (eg. "John Smith") in the from address when using Ruby 1.8 and ActionMailer::Base.delivery_method = :smtp

This can be replicated by setting ActionMailer::Base.delivery_method = :smtp, and creating a simple test mailer:

class TestMailer < ActionMailer::Base
  def test_email
    subject     "this is a test of the 2.3.3 mailer"
    recipients  %(Travis Sinnott <>)
    from        %(John Smith <>)

The specific change in action_mailer/base.rb:

-        sender = (mail['return-path'] && mail['return-path'].spec) || mail.from
+        sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']

The difference between these methods is that the former returns an array of strings containing only the address part (eg. ""), whereas the later returns a TMail::AddressHeader object.

When passed to Net::SMTP, the value of sender is put directly into the argument for the MAIL FROM command. TMail::AddressHeader.to_s returns "John Smith", which causes the SMTP server to return a 501 error code:

Net::SMTPSyntaxError (501 < John Smith>: "@" or "." expected after "John"
): /usr/local/lib/ruby/1.8/net/smtp.rb:930:in check_response' /usr/local/lib/ruby/1.8/net/smtp.rb:899:ingetok' /usr/local/lib/ruby/1.8/net/smtp.rb:828:in mailfrom' /usr/local/lib/ruby/1.8/net/smtp.rb:653:insendmail' /usr/local/lib/ruby/1.8/net/smtp.rb:526:in start' app/models/test_item.rb:9:insend_test_email' app/controllers/test_items_controller.rb:46:in create' app/controllers/test_items_controller.rb:45:increate'

Using delivery_method = :sendmail, or omitting the display name from the address are both effective work-arounds.

Comments and changes to this ticket

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=""></a>


Referenced by