This project is archived and is in readonly mode.

#2340 ✓resolved
Friedrich Göpel

action mailer can't deliver mail via smtp on ruby 1.9.1 or 1.8.7

Reported by Friedrich Göpel | March 25th, 2009 @ 05:02 PM | in 2.3.6

Ruby: ruby 1.9.1p0 (2009-03-04 revision 22762) [i386-darwin9.6.0] Rails: edge rails revision: 6ed42ebdff05f9d28a60e91093d8f9afad03a958

Delivering e-mail via smtp on ruby 1.9.1 fails. Turning on debugging in postfix reveals the cause:


MAIL FROM:<["friedrich.goepel@gmail.com"]>

Of course the square brackets are illegal here and make it impossible for the mail server to deliver the mail.

A little digging into action mailer reveals: - in perform_delivery_smtp the sender is passed to Net::SMTP as an Array here:


 smtp.sendmail(mail.encoded, sender, destinations)
  • it works when changing the line to:

 smtp.sendmail(mail.encoded, sender.first, destinations)
  • Apparently a Array is passed in ruby 1.8 as well, where it works as is.
  • Passing a String works in 1.8 as well.

Now when diffing ruby 1.8 and 1.9.1 net/smtp.rb one finds this:


-    def mailfrom( fromaddr )
-      getok('MAIL FROM:<%s>', fromaddr)
+    def mailfrom(from_addr)
+      getok("MAIL FROM:<#{from_addr}>")

So it seems this worked before just by sheer accident, multiple senders aren't possible anyway, so passing an Array here makes little sense.

Further investigation leads to the discovery that the Array wrapping happens in TMail, and switching the mail.from to mail['from'] fixes the problem as well and more cleanly.

So here's a oneliner patch to do just that.

Enjoy. :)

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages