This project is archived and is in readonly mode.
action mailer can't deliver mail via smtp on ruby 1.9.1 or 1.8.7
-
Joren Six
I can confirm this bug. In postfix it gives this:
warning: Illegal address syntax from unknown[xx.xx.xx.xx] in MAIL command: ["user@example.com"]
The exception in rails itself:
Net::SMTPSyntaxError 501 5.1.7 Bad sender address syntax
Let's hope that this comment makes it easier to google this problem.
Anyway thanks for the fix!
-
Alexander Lang
+1 from me. i get the same error with postfix.
-
korch
+1 from me too, getting the exact same error right now with postfix
-
Friedrich Göpel
- Tag changed from 2.3.2, actionmailer, bug, edge, email, ruby1.9, ruby19 to 2.3, 2.3.2, 2.3.x, actionmailer, bug, edge, email, patch, ruby1.9, ruby19, smtp
-
Michael Koziarski
- State changed from new to resolved
-
Tom Stuart
This commit broke SMTP sends in my Rails project (on Ruby 1.8).
When the TMail object is instantiated with a From header that includes a recipient name and email address (e.g. "John Doe john@doe.com"),
mail.fromreturns just the email address (e.g. "john@doe.com"), which is the correct syntax for SMTP's MAIL FROM command. However,mail['from']returns the verbatim From string (e.g. "John Doe john@doe.com") which is invalid syntax and causes the SMTP server to barf.Breaking support for named senders in exchange for Ruby 1.9 compatibility isn't an acceptable tradeoff. If you don't want an array, the
sender.firstsolution is the right one. -
Michael Koziarski
- State changed from resolved to open
- Milestone changed from 2.x to 2.3.4
Tom,
Can you provide a patch (complete with test case) which demonstrates this problem?
I'm frozen to 2-3-stable and stuff's working ok for me, so I'm obviously doing something wrong.
-
Joey A
Here's a patch that fixes the pre-1.9 issue for me. I've included the tests provided by Josh Nichols at #2945 ActionMailer generates invalid SMTP commands when from contains name.
-
Joey A
Previous link got corrupted. Here's the other thread:
#2945 ActionMailer generates invalid SMTP commands when from contains name
-
Michael Koziarski
- Assigned user set to Michael Koziarski
-
Michael Siebert
+1 for Joey A's patch!
just applied it to our production app, it saved our night
this bug is a real showstopper... -
Michael Koziarski
Joey,
Could you attach it as a proper git format-patch patch, that way
you'll get the right credit.Happy to apply to 2-3-stable and master, will be fixed in 2.3.4
-
Levin Alexander
attached is Joeys patch as git-format-patch.
-
Josh Nichols
+1, as I was running into it on #2945 ActionMailer generates invalid SMTP commands when from contains name :) I verified the patch addresses the problem on 1.8 and 1.9.
Given the mailer:
class Blah < ActionMailer::Base def blah from "Tester McTesty <test@test.com>" recipients "Josh Nichols <josh@technicalpickles.com>" subject "blah" end endOutput before the patch is incorrect for 1.8 and 1.9, according to mailtrap:
* Message begins From: <Tester McTesty <test@test.com>> To: <josh@technicalpickles.com> Body: Date: Sat, 8 Aug 2009 11:43:40 -0400 From: Tester McTesty <test@test.com> To: Josh Nichols <josh@technicalpickles.com> Message-Id: <4a7d9d2ce0ff_540558b421df@technicalpickles.local.tmail> Subject: blah Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 * Message endsAfter applying the patch, it is corrected:
* Message begins From: <test@test.com> To: <josh@technicalpickles.com> Body: Date: Sat, 8 Aug 2009 11:42:06 -0400 From: Tester McTesty <test@test.com> To: Josh Nichols <josh@technicalpickles.com> Message-Id: <4a7d9cce149d7_53d158b421c1@technicalpickles.local.tmail> Subject: blah Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 * Message ends -
Peter Boling
Bug is NOT just on Ruby 1.9.1. I have the problem on Ruby 1.8.7. I assume anything that runs rails 2.3.3 will be unable to send email with a "Name" format.
This is a show stopper. Please release a new rails with this patch! The
-
Dmitry Polushkin
I've added a fix in initializer for Rails 2.3.3 (fix_mailer_on_rails_2.3.3.rb):
module ActionMailer class Base def perform_delivery_smtp(mail) destinations = mail.destinations mail.ready_to_send sender = (mail['return-path'] && mail['return-path'].spec) || Array(mail.from).first smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port]) smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto) smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp| smtp.sendmail(mail.encoded, sender, destinations) end end end endLets wait till the end of the month, when 2.3.4 will be released.
-
Mark G
Thanks Dmitry. The initialiser was very helpful.
-
Larry Sprock
Why did this not get applied to rails 2.3.4? Seems like a no brainer. Thanks to Dmitry for a work around.
-
Dmitry Polushkin
Ouch, still not patched? Why not in 2.3.4?
-
Joshua Siler
Just plowed head long into this issue using 2.3.4 and ruby 1.8. Is the patch in the queue for next release?
-
Curtis Hawthorne
+1 from me. I just ran into this issue after upgrading from 2.2. I'm running ruby 1.8. For now, I'm using Dmitry's workaround, but it would be great to get this in the release.
-
robduncan
- I am also experiencing this issue. Dmitry Polushkin's workaround works for me.
-
Josh Nichols
Verified this is a still problem on 2.3.4.
Are there any issues with the attached patches? Would really like to see this fixed so I don't have to monkey patch ActionMailer in an initializer.
-
Levin Alexander
We're using the Patch by Joey A. successfully in production.
+1
-
Levin Alexander
#3078 ActionMailer 2.3.3 broke display name support in from address when using SMTP is a duplicate of this ticket
-
Joe Van Dyk
So this problem doesn't just happen with ruby 1.9? If so, the ticket title should be updated.
-
Zachery Hostens
in response to Josh Nichol's Post:
Why on earth are emails being sent with multiple From/To lines?
-
Zachery Hostens
nm. i imagine the paste is slightly different than actual output and one is MAIL FROM/RCPT TO, and other is just From/To.
Apologize.
-
Paul Campbell
I got this today on 1.8.6 on Engine Yard, on Rails 2.3.3 and 2.3.4 ....
It's a shame this didn't make it in to 2.3.4 ... seems like it's a pretty serious bug, and I can't imagine too many people using mailers that send with just an email address. It would essentially break any app that relied on named mailers that upgraded to 2.3.3 or 2.3.4.
Is 2.3.5 on the cards soon? Would something like this not warrant a small point release?
-
Gabe da Silveira
I agree with Paul. This bug is nasty. Our site was not sending emails for an hour after deploying. To make matters worse, exception notifier was broken too so we were not notified of the problem. This should be pushed out as a point release immediately. This kind of thing can do real damage to production apps.
-
Christian Seiler
Gabe, I had to go through the exact same. No registration emails, no exception notifications. This is by far the most critical issue I had with Rails so far. And it's a shame that nothing has happened such a long time.
-
Scott Johnson
+1, this is worth a point release by itself. This is a show stopper and it has been broken for months now. A real shame.
-
Aaron
Please fix!
-
Christian Seiler
We should start a tweet blast or something to get some awareness
-
Dmitry Polushkin
My another +1 for this ticket.
-
thenobot
I had the same problem with ActionMailer 2.2.2 and Ruby 1.8.7-174 with Postfix.
A workaround is to add the following line to your notification methods:
from "Me <noreply@mydomain.com>"- headers "return-path" => 'noreply@mydomain.com' subject "Here is the Subject!"
Not sure if that works for the versions of ActionMailer and Ruby in question...
-
thenobot
Oh barf, my first post and I mess up the formatting. The workaround looks like:
from "Symantec Health <noreply@symantechealth.com>" + headers "return-path" => 'noreply@symantechealth.com' subject "New Symantec Health Sales Lead!" -
Chris Lee
+1 for this ticket and for Dmitry's code.
-
Nathaniel Bibler
+1 for this issue being seen in production and successful use of Dmitry's initializer code in Rails 2.3.4 with MRI Ruby 1.8.7.
-
owain
- Tag changed from 2.3, 2.3.2, 2.3.x, actionmailer, bug, edge, email, patch, ruby1.9, ruby19, smtp to 1.8.7, 2.3, 2.3.2, 2.3.x, actionmailer, bug, edge, email, patch, ruby, ruby1.9, ruby19, smtp
- Title changed from action mailer can't deliver mail via smtp on ruby 1.9.1 to action mailer can't deliver mail via smtp on ruby 1.9.1 or 1.8.7
It took an absolute age (4 hours) to find this post. Perhaps a better title such as Net::SMTPFatalError (553) Invalid mail address might make it somewhat easier to search for in future. At least that's what I was getting.
Certainly on ruby 1.8.7
-
owain
- Tag cleared.
Posted a stub on the Ruby on Rails talk site to help people pick this up.
http://groups.google.com/group/rubyonrails-talk/browse_thread/threa... -
Rob Bean
- Assigned user cleared.
+1 to thenobot's solution.
Using the name and email in "From" and adding the "return-path" header resolved the issue for me.
Ruby 1.8.7
Rails 2.3.4 -
Michael Koziarski
- State changed from open to resolved
Missed 2.3.5 for this one, sorry.
It's resolved in 2-3-stable and master so will be fixed in 3.x and 2.3.6
-
bhauff
The initializer from Dmitry Polushkin fixed my broken apps.
-
Chris Kampmeier
In case anybody's looking for them, the commits that fix this are
da61a6c9on 2-3-stable and7e0aa35con master.
