On Tue, Mar 6, 2012 at 5:28 PM, Scott Macri <scottma...@gmail.com> wrote:
> I'm attempting to send a message from my django app via gmail and keep
> getting a connection refused error even though I know the parameters
> are correct.
>
> settings.py
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_PORT = '587'
> EMAIL_USE_TLS = True
> EMAIL_HOST_USER = 'myu...@gmail.com'
> EMAIL_HOST_PASSWORD = 'password'
>
> idle command:
> send_mail('My First Subject','My First Email Message in
> DJango','myu...@gmail.com',['someb...@gmail.com'],fail_silently=False)
>
> I am able to send email through my mail client (Thunderbird).
>
> Any insight on this matter would be greatly appreciated.  Thanks.
>
> ********* The error message is below ************
>
> Traceback (most recent call last):
>  File "<console>", line 1, in <module>
>  File "/Library/Python/2.6/site-packages/django/core/mail/__init__.py",
> line 61, in send_mail
>    connection=connection).send()
>  File "/Library/Python/2.6/site-packages/django/core/mail/message.py",
> line 251, in send
>    return self.get_connection(fail_silently).send_messages([self])
>  File "/Library/Python/2.6/site-packages/django/core/mail/backends/smtp.py",
> line 79, in send_messages
>    new_conn_created = self.open()
>  File "/Library/Python/2.6/site-packages/django/core/mail/backends/smtp.py",
> line 42, in open
>    local_hostname=DNS_NAME.get_fqdn())
>  File 
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py",
> line 239, in __init__
>    (code, msg) = self.connect(host, port)
>  File 
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py",
> line 295, in connect
>    self.sock = self._get_socket(host, port, self.timeout)
>  File 
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py",
> line 273, in _get_socket
>    return socket.create_connection((port, host), timeout)
>  File 
> "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py",
> line 512, in create_connection
>    raise error, msg
> error: [Errno 61] Connection refused
>

Connection refused is pretty clear. Something is stopping outgoing
connections from reaching smtp.gmail.com.

You didn't specify whether thunderbird and django running on the same
machine - are they?

If you go to a console on the machine where django is running, and
type in "telnet smtp.gmail.com 587", you should get an output like
this:

> $ telnet smtp.gmail.com 587
Trying 173.194.67.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP 9sm82106435wid.2

If not, you must have a firewall somewhere between that box and google
that is refusing the connection.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to