Monday, May 3, 2010

PEAR Mail.php - Failed to add recipient (code: 451)

I decided to use the PEAR mailer for a web project in order to send emails through my SMTP server. However, I was getting a strange error:
Failed to add recipient: xxxxx@gmail.com [SMTP: Invalid response code received from server (code: 451, response: Temporary local problem - please try later)]

Yikes! That is not a very helpful error. If the server doesn't know what what the response code means, how am I supposed to? Using SSH, I took a look at the exim_rejectlog located at /var/log and found that my mail server didn't particularly care for the source or 'From' email address.

After a bit of trial and error, it became clear that 'From' address must match the SMTP account's address. It is a nice anti-abuse feature (for shared servers) that I wasn't even aware of.

Anyway, if you get this error, it probably could be a number of things, but be sure to check that your 'From' email address matches the email address of the SMTP account you are using to send the email.

No comments: