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',['some...@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
--
Scott
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
Trying 74.125.45.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP v26sm52104286yhk.1
I can run thunderbird on the same machine and don't have any issues.
No, I am not running tbird at the same time as the django app. Thus,
I know it's not a port conflict.
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
--
Scott A. Macri
www.ScottMacri.com
(571) 234-1581
It wouldn't make any difference if you were running your Django app and
T'bird at the same time. The port that the Django dev server uses has
nothing to do with the port the Gmail SMTP server uses. Even if your
Django app were to send email at precisely the same time as T'bird, it
wouldn't make any difference. SMTP servers are designed to handle
multiple simultaneous connections.
--
Regards,
Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada M4N 3P6
Because, as JJO stated, the code you show is NOT what Django does when
establishing a secure email connection. The code you showed
establishes an SSL connection to the email server. The
smtplib.SMTP_SSL method you show is a feature new in Python 2.6.
Django still supports Python 2.5, so cannot use this method. The older
way of establishing a secure connection to an email server is to begin
with a non-encrypted connection and upgrade it to secure via the
STARTTLS command. This is what Django does when you specify
EMAIL_USE_TLS=True. Gmail doc notes that for the TLS/STARTTLS case,
you need to use port 587:
http://support.google.com/mail/bin/answer.py?hl=en&answer=13287
Karen
--
http://tracey.org/kmt/