RSS

Django send_mail “Connection refused” on MacOS X

29 May

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'
EMAIL_PORT = 1025

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
From: info@test.com
To: test@test.com
Date: Sat, 28 May 2011 18:31:04 -0000
Message-ID: <20110528183104.11696.10011@dasha-salos-macbook-pro.local>
X-Peer: 127.0.0.1

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

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

Advertisements
 
Leave a comment

Posted by on May 29, 2011 in misc

 

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: