Email notice in python: "Recipient address rejected: Access denied"



I wrote forms in Python for an event website and they worked perfectly fine last year. However, now I’m having trouble sending email notifications to event coordinators. I’m a “Recipient address rejected: Access denied” error:

[Mon Oct 15 08:58:12 2012] [error] [client] Traceback (most recent call last):, referer: [Mon Oct 15 08:58:12 2012] [error] [client] File "", line 62, in <module>, referer: [Mon Oct 15 08:58:12 2012] [error] [client] smtpserv.sendmail(msgemail, msgto, msg.as_string()), referer: [Mon Oct 15 08:58:12 2012] [error] [client] File "/usr/lib/python2.5/", line 703, in sendmail, referer: [Mon Oct 15 08:58:12 2012] [error] [client] raise SMTPRecipientsRefused(senderrs), referer: [Mon Oct 15 08:58:12 2012] [error] [client] smtplib.SMTPRecipientsRefused, referer: [Mon Oct 15 08:58:12 2012] [error] [client] : , referer: [Mon Oct 15 08:58:12 2012] [error] [client] {'': (554, '5.7.1 <>: Recipient address rejected: Access denied'), '': (554, '5.7.1 <>: Recipient address rejected: Access denied')}, referer: [Mon Oct 15 08:58:12 2012] [error] [client] Premature end of script headers:, referer:

Both addresses work perfectly fine. Any clue as to why it would misbehave?

Thanks for your help,



You may be running afoul of our changed spam filters:

I would guess the headers are what’ causing the problem


Cool, but I’m emailing myself and another guy on the team, I can’t be breaching any of these. Here’s the (python) code for sending notifications:

[code]from email.mime.text import MIMEText

Send email to

msgemail = ""
msgto = [msgemail,“”]
msgtxt = “”"

Nouvelle soumission de bénévole: %s
Plus d'information à

– Le robot

""" % form.getvalue("name") msg = MIMEText(msgtxt, 'html') msg['subject'] = "Nouvelle soumission de bénévole: %s" % form.getvalue("name") msg['From'] = msgemail msg['To'] = ", ".join(msgto) smtpserv = smtplib.SMTP('localhost') smtpserv.sendmail(msgemail, msgto, msg.as_string())[/code]

I don’t know what the spam filter is doing, but I really don’t see what’s turning this into a false positive. Can you tell me?

Thanks for your help!


Who’s the ‘from’ from?

The spam check is partly on who sent the email. So if you’re sending from (i.e. your registered domain with us) to (my mother’s alma mater!), that’s fine. But if you’re sending from a address, that would do it.


msgemail = "", so that’s indeed what I’m sending it from – and to as well (there’s two recipients). Could it be the problem? Sending things to oneself?


Looks like you’re sending mail via SMTP to localhost, possibly unintentionally — if you’re doing this, you need to have your script identify itself to the server using your shell username and password. Otherwise we end up losing track of what user sent the email.

A simpler alternative is to forego smtplib and run sendmail directly. See the code at the end of for an example of how to do this.


Shouldn’t be…

Alright, it appears that SMTP to localhost now requires authentication with your shell username and password.

If possible, we recommend that you use /usr/sbin/sendmail instead of local SMTP. There’s a brief explanation of how to do so here:


I see. Thank you! I did it your way, and it works fine!