我想通過Django發送電子郵件作爲django-userena的一部分,但我無法收到電子郵件發送。在我的設置,我有:Django電子郵件不發送
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'mypassword'
我試圖從Django的控制檯發送一封電子郵件,其中:
from django.core.mail import EmailMessage
email = EmailMessage('Mail Test', 'This is a test', to=['[email protected]'])
email.send()
它掛在發送命令,並不實際發送電子郵件。如果我停止命令,我得到這個回溯:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/myuser/Copy/Projects/Programming/myproject/venv/local/lib/python2.7/site-packages/django/core/mail/message.py", line 274, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/myuser/Copy/Projects/Programming/myproject/venv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 87, in send_messages
new_conn_created = self.open()
File "/home/myuser/Copy/Projects/Programming/myproject/venv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 48, in open
local_hostname=DNS_NAME.get_fqdn())
File "/usr/lib/python2.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 312, in connect
(code, msg) = self.getreply()
File "/usr/lib/python2.7/smtplib.py", line 356, in getreply
line = self.file.readline()
File "/usr/lib/python2.7/socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
任何幫助,爲什麼這是不經過?
檢查此問題:http://stackoverflow.com/questions/1950442/connection-timeout-issue-sending-email-in-django – ruddra 2014-09-02 06:22:23