Tag Archives: mail

Django send_mail “Connection refused” on MacOS X

Connection refused

If you are getting “Connection refused” error message when trying to send an email from Django with send_mail then one thing to check is whether Postfix is running on your Mac OS X.

For that try the following in the terminal:

sudo postfix status

If Postfix is not running then start it.

postfix/postfix-script: the Postfix mail system is not running

sudo postfix start
postfix/postfix-script: starting the Postfix mail system

This should solve the problem (assuming email settings are correct). For example for localhost:

EMAIL_HOST = 'localhost'

For debugging purposes you could use a local smtp server:

python -m smtpd -n -c DebuggingServer localhost:1025

Try to send an email with Django and you should see it in your terminal:

---------- MESSAGE FOLLOWS ----------
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Subject: Subject here
Date: Sat, 28 May 2011 18:31:04 -0000
Message-ID: <20110528183104.11696.10011@dasha-salos-macbook-pro.local>

Here is the message.
------------ END MESSAGE ------------

You can find more info on testing Django email in the documentation.

Leave a comment

Posted by on May 29, 2011 in misc


Tags: , ,

%d bloggers like this: