SMTPSyntaxError (501 <>: missing or malformed local part

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.smith@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.