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


#1

Hi,

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 192.75.139.253] Traceback (most recent call last):, referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] File "volunteerform-submit.py", line 62, in <module>, referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] smtpserv.sendmail(msgemail, msgto, msg.as_string()), referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] File "/usr/lib/python2.5/smtplib.py", line 703, in sendmail, referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] raise SMTPRecipientsRefused(senderrs), referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] smtplib.SMTPRecipientsRefused, referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] : , referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] {'firat.akova@mail.mcgill.ca': (554, '5.7.1 <firat.akova@mail.mcgill.ca>: Recipient address rejected: Access denied'), 'info@philopolis.net': (554, '5.7.1 <info@philopolis.net>: Recipient address rejected: Access denied')}, referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr [Mon Oct 15 08:58:12 2012] [error] [client 192.75.139.253] Premature end of script headers: volunteerform-submit.py, referer: http://www.philopolis.net/mtl/volunteerform.py?lang=fr

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

Thanks for your help,

Louis


#2

You may be running afoul of our changed spam filters: http://dreamhost.com/anti-spam-policy/

I would guess the headers are what’ causing the problem


#3

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 info@philopolis.net

msgemail = "info@philopolis.net"
msgto = [msgemail,“firat.akova@mail.mcgill.ca”]
msgtxt = “”"

Nouvelle soumission de bénévole: %s
Plus d'information à http://www.philopolis.net/mtl/benevoles.py

– 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!


#4

Who’s the ‘from’ from?

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


#5

msgemail = "info@philopolis.net", 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?


#6

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 http://effbot.org/pyfaq/how-do-i-send-mail-from-a-python-script.htm for an example of how to do this.


#7

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: http://stackoverflow.com/a/74084


#8

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