Send email using Gmail, Django, and Mezzanine

Posted March 18, 2015 6.3k views
Email Django

I’m trying to send notification emails using Django (1.6.1) and Mezzanine on Ubuntu 14.04. This is in my


This returns: [Errno 111] Connection refused

But I can send email from the console like this:

>> from django.core.mail import send_mail
>> send_mail('Subject here', 'Here is the message.', '',
    [''], fail_silently=False)

It return 1 and I actually got the email. I’ve tried Mandrill as well and got the same results.

After reading various threads, do I need to install Postfix to act as a relay or can I directly access the SMTP servers and email? I’d like to avoid installing Postfix if possible.

1 comment
  • On first blush, those settings look correct to me. Have you set up any firewalling on the server? I’d expect a SMTPAuthenticationError rather than “Connection refused” if it was being rejected by Google. Is there a full traceback for the error? It’s very strange that it succeeds from the console but not from your app. Could you share a snippet of the actual code in app?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Same issue here:

from django.core.mail import sendmail
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “/opt/apps/.virtualenvs/sentry/local/lib/python2.7/site-packages/django/core/mail/”, line 50, in sendmail
File “/opt/apps/.virtualenvs/sentry/local/lib/python2.7/site-packages/django/core/mail/”, line 276, in send
return self.getconnection(failsilently).sendmessages([self])
File “/opt/apps/.virtualenvs/sentry/local/lib/python2.7/site-packages/django/core/mail/backends/”, line 87, in send
newconncreated =
File “/opt/apps/.virtualenvs/sentry/local/lib/python2.7/site-packages/django/core/mail/backends/”, line 48, in open
File “/usr/lib/python2.7/”, line 256, in _
(code, msg) = self.connect(host, port)
File “/usr/lib/python2.7/”, line 316, in connect
self.sock = self.getsocket(host, port, self.timeout)
File “/usr/lib/python2.7/”, line 291, in getsocket
return socket.createconnection((host, port), timeout)
File “/usr/lib/python2.7/”, line 571, in create
raise err
error: [Errno 101] Network is unreachable

Submit an Answer