Error sending email from python cron job


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 Recipient address rejected: Access denied

The script I am using is the from this project:

Has something changed in how dreamhost handles email?


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.


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.


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:

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


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

[jerusalem]$ telnet localhost 25
Connected to localhost.
Escape character is '^]'.
helo mail.localhost
250 2.1.0 Ok
554 5.7.1 <>: Recipient address rejected: Access denied

Any ideas?


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:


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


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 Connected to localhost. Escape character is '^]'. 220 ESMTP helo marvin 250 mail 250 2.1.0 Ok rcpt 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.


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