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.