Error sending email from python cron job


#1

I have a python script that I run through cron. This script collects some information, then sends out an email. This script worked fine until a few months ago. Nothing has changed on my side (no updates to the script or python libraries it uses), so I’m guessing something has changed on the dreamhost side.

The error message I get when the script tries to send an email is:

SMTP error: server refused recipient: 554 5.7.1 user@xxx.com: Recipient address rejected: Access denied

The script I am using is the bzr_hookless_email.py from this project:
https://launchpad.net/bzr-hookless-email

Has something changed in how dreamhost handles email?


#2

Does not look like a problem with Dreamhost. Whatever service you use to receive those e-mails isn’t accepting e-mails for your e-mail address.


#3

Except the email address I’m sending to is hosted at dreamhost. This used to work for all email addresses, and now all email addresses are failing.


#4

Oh OK, I suppose it would have been more correct to say that the error is not with the python cron job, as the title of this thread suggests. Well at least not according to the error message.

Have you tried sending e-mails to those same e-mail addresses from somewhere else?[hr]
You can also test your e-mail with telnet to port 25

Here are a few posts about how to do that:
http://bobpeers.com/technical/telnet_smtp
http://arnab.org/node/449

If your e-mail address isn’t accepted, check through the panel that you actually have it set up properly.


#5

Following the first link, I tried to telnet into the server, here’s what I got:

[jerusalem]$ telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 jerusalem.dreamhost.com ESMTP
helo mail.localhost
250 jerusalem.dreamhost.com
mail from:xxx@xxx.com
250 2.1.0 Ok
rcpt to:yyy@xxx.com
554 5.7.1 <yyy@xxx.com>: Recipient address rejected: Access denied

Any ideas?


#6

SMTP to localhost now requires authentication with your shell username and password. This change was necessary to allow us to track the source of some bulk email.

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


#7

Thanks andrewf. I didn’t realize it had to be our shell username and password! Using that to authenticate works!


#8

Well this is odd, because I can send an e-mail without authentication from my Dreamhost user via localhost, and the e-mail arrived.

$ telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 ps9296.dreamhostps.com ESMTP helo marvin 250 ps9296.dreamhostps.com mail from:otto@mydomain.com 250 2.1.0 Ok rcpt to:info@mydomain.ee 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> Test 2 . 250 2.0.0 Ok: queued as CA38D62E84D0 quit 221 2.0.0 Bye Connection closed by foreign host. [hr]
On second thought, I suppose it’s because I am on a VPS and the restriction is probably only for shared hosting.


#9

Correct. We only need the extra information to distinguish between customers on shared hosting servers.