This project is archived and is in readonly mode.
ActionMailer generates invalid SMTP commands when from contains name
Reported by Josh Nichols | July 23rd, 2009 @ 06:24 PM | in 2.x
After upgrading to 2.3.3, I began getting this error when delivering mail over SMTP:
Net::SMTPSyntaxError: 501 <"Fan Vs. Fan Notification" <do_not_reply@fanvsfan.com>>: "@" or "." expected after ""Fan Vs. Fan Notification""
/usr/lib64/ruby/1.8/net/smtp.rb:679:in `check_response'
/usr/lib64/ruby/1.8/net/smtp.rb:652:in `getok'
/usr/lib64/ruby/1.8/net/smtp.rb:630:in `mailfrom'
/usr/lib64/ruby/1.8/net/smtp.rb:543:in `send0'
/usr/lib64/ruby/1.8/net/smtp.rb:471:in `sendmail'
vendor/rails/actionmailer/lib/action_mailer/base.rb:683:in `perform_delivery_smtp'
/usr/lib64/ruby/1.8/net/smtp.rb:378:in `start'
vendor/rails/actionmailer/lib/action_mailer/base.rb:681:in `perform_delivery_smtp'
vendor/rails/actionmailer/lib/action_mailer/base.rb:523:in `__send__'
vendor/rails/actionmailer/lib/action_mailer/base.rb:523:in `deliver!'
vendor/rails/actionmailer/lib/action_mailer/base.rb:395:in `method_missing
lib/debatable.rb:428:in `send_notification'
The code that was used is something along the lines of:
class Mailer < ActionMailer::Base
def debate_challenge_notification(user, debate)
from "Fan Vs. Fan Notification" <do_not_reply@fanvsfan.com>"
# snip for brevity
end
end
I popped open mailtrap to see what it was actually sending over the line, and it was:
Helo: EHLO mydomain.net
Seen an EHLO
From: MAIL FROM:<"Fan Vs. Fan Notification" <do_not_reply@fanvsfan.com>>
To: RCPT TO:<josh@technicalpickles.com>
+ Date: Wed, 22 Jul 2009 22:47:11 -0400
+ From: "Fan Vs. Fan Notification" <do_not_reply@fanvsfan.com>
The problem is that it's wrapping the entire 'from' with less-than and greater-than. I looked back at what it was doing before 2.3.3, and it seems to behave correctly:
From: MAIL FROM:<do_not_reply@fanvsfan.com>
To: RCPT TO:<josh@technicalpickles.com>
+ Date: Wed, 22 Jul 2009 23:26:19 -0400
+ From: "Fan Vs. Fan Registration" <do_not_reply@fanvsfan.com>
After digging around ActionMailer and TMail, I found traced the difference to this commit:
http://github.com/rails/rails/commit/72d111a21ca21460a320d7611b1fdf...
The commit message says it's for a 1.9 issue, but it looks that mail['from'] returns exactly the thing you specified in the mailer, whereas the old way of just returns the email part of it. I've created some tests which expose this problem, but I'm not sure of the best way to fix it and have it work with 1.9.
Comments and changes to this ticket
-
Maxi Musi July 28th, 2009 @ 09:32 AM
Maybe my error comes from the same issue:
users#create (Net::SMTPFatalError) "555 5.5.2 Syntax error. 24sm4141505bwz.87\n"
I'm using Ruby 1.8.7!
Error occured when switching to Rails 2.3.3. When I backswitch it works again.
Cannot provide further information, sorry. -
Joey A July 28th, 2009 @ 10:53 PM
The patch I uploaded at
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...
fixes this issue for me in ruby 1.8.6. Josh, I included your tests there.
-
Michael Koziarski July 29th, 2009 @ 02:49 AM
- State changed from new to duplicate
will fix this in #2340
-
csnk May 18th, 2011 @ 08:20 AM
- Importance changed from to
We are the professional jeans manufacturer, jeans supplier, jeans factory, custom jeans.
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>
People watching this ticket
Attachments
Tags
Referenced by
- 2340 action mailer can't deliver mail via smtp on ruby 1.9.1 +1, as I was running into it on #2945 :) I verified the p...
- 3078 ActionMailer 2.3.3 broke display name support in from address when using SMTP Yep. This is a duplicate of #2340 / #2945, and Joey A's p...
- 2340 action mailer can't deliver mail via smtp on ruby 1.9.1 Here's a patch that fixes the pre-1.9 issue for me. I've ...
- 2340 action mailer can't deliver mail via smtp on ruby 1.9.1 https://rails.lighthouseapp.com/projects/8994/tickets/2945