Problems with ActionMailer: 501 <>: missing or malformed local part
-
19-09-2019 - |
Question
I'm having trouble sending mail using SMTP from a Rails app. I have a Mailer
class:
class Mailer < ActionMailer::Base
def newsletter_confirmation(subscription)
recipients "my-valid-email@gmail.com" # this is set to my email
# just for testing purposes and will
# be changed to subscription.email
from "\"my-valid-helo-domain.net\" <noreply@my-valid-helo-domain.net>"
subject "Confirm your subscription"
body :subscription => subscription
end
end
When I try to send the mail, I get a Net::SMTPSyntaxError
:
501 <["noreply@my-valid-helo-domain.net"]>: missing or malformed local part
If I comment out the from
field, the mail gets delivered ok, but with the from information missing (obviously).
Any ideas on what I'm doing wrong?
Thanks.
Edit: I'm using Rails 2.3.2 and Ruby 1.9.1
Solution
The error code and the description of the error states that this is an error on the mail server.
I suggest you check the mail servers to pinpoint the error.
When it comes to ActionMailer it is supposed to raise an exception if the configuration parameter raise_delivery_errors is set (default in Production but not in Development I believe), so you can check that one and try to resend if it triggers.
EDIT:
Here is the solution (it's a Ruby/Rails 1.9 bug):
and the patch:
OTHER TIPS
It is a known bug. https://rails.lighthouseapp.com/projects/8994/tickets/2340