SMTPSyntaxError (501 <>: missing or malformed local part)

65 views
Skip to first unread message

Jim Jones

unread,
Aug 28, 2006, 2:00:28 AM8/28/06
to rubyonra...@googlegroups.com
I get this when trying to send out an email. What exactly does this
error mean?
________________________________________

Net::SMTPSyntaxError (501 <>: missing or malformed local part
):
/usr/lib/ruby/1.8/net/smtp.rb:680:in `check_response'
/usr/lib/ruby/1.8/net/smtp.rb:653:in `getok'
/usr/lib/ruby/1.8/net/smtp.rb:635:in `rcptto'
/usr/lib/ruby/1.8/net/smtp.rb:546:in `send0'
/usr/lib/ruby/1.8/net/smtp.rb:545:in `send0'
/usr/lib/ruby/1.8/net/smtp.rb:472:in `sendmail'
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:513:in
`perform_delivery_smtp'
/usr/lib/ruby/1.8/net/smtp.rb:379:in `start'
/usr/lib/ruby/1.8/net/smtp.rb:316:in `start'
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:511:in
`perform_delivery_smtp'
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:397:in
`deliver!'
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:291:in
`method_missing'
/app/controllers/workout_controller.rb:58:in `notifyNewWorkout'

--
Posted via http://www.ruby-forum.com/.

Matias Surdi

unread,
Aug 28, 2006, 7:55:34 AM8/28/06
to rubyonra...@googlegroups.com
I think that you are entering some mail addres (to or from) in the wrong
format.

They usually are something like:

"This is my name" <myn...@mydomain.com>

Jim Jones escribió:

Jim Jones

unread,
Aug 28, 2006, 12:09:56 PM8/28/06
to rubyonra...@googlegroups.com
How can I catch this so that when my function fails, I can just move on
to the next user? My email function looks like this:

class NewWorkoutNotify < ActionMailer::Base

def notify_new_workout(user)
# Email header info MUST be added here
@recipients = user.email

@from = "x...@yyyy.net"
@subject = "New Workout Ready"

# Email body substitutions go here
@body["login"] = user.login
end

end

Matias Surdi wrote:
> I think that you are entering some mail addres (to or from) in the wrong
> format.
>
> They usually are something like:
>
> "This is my name" <myn...@mydomain.com>
>
>
>
> Jim Jones

>escribi󺊦gt;

Anthony Altemara

unread,
Sep 12, 2008, 1:09:30 PM9/12/08
to rubyonra...@googlegroups.com
I had this error when I screwed up the 'recipients XXXXXX' line in my
mailer model.

I had 'recipients = XXXXXX' instead of 'recipients XXXXXX'

I found this by adding some logger.info statements in:

/usr/lib/ruby/gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb

...in the deliver! method. I then saw that there were no recipients
being given to net::smtp


Good luck!

Something that may also help debugging, you can hack
/usr/lib/ruby/1.8/net/smtp.rb and add a few print statements inside
get_response, recv_response, and getok, in order to see what is actually
coming to and from the SMTP server.

This helped me immensely. Be warned however, as this will cause ugly
text to be printed on every app on your server that uses these
libraries.

Anthony Altemara

unread,
Oct 22, 2009, 9:23:11 PM10/22/09
to rubyonra...@googlegroups.com
I have seen this error as well, and found the problem to be the email
address having a leading 'space'.

For example, I was passing an email address like this: " Bob Smith
<bob....@gmail.com>" and was getting the error.

As soon as I stripped the space away with '.strip' before I assigned it
to 'recipients', the error went away.

Not sure which part of the code (gem or ruby) was choking on the
whitespace. I didn't investigate further. I am using Action::Mailer
2.2.2.

Reply all
Reply to author
Forward
0 new messages