我一直在尝试让我的项目能够使用电子邮件,我相信已经正确配置了。这里是我的settings.py文件、我运行的命令以及当我停止它时得到的traceback信息。
邮件配置:
邮件配置:
#Email Configuration
DEFAULT_FROM_EMAIL = #Email Address
SERVER_EMAIL = #Email Address
EMAIL_USE_TLS = True
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_HOST_USER = #Email Address
EMAIL_HOST_PASSWORD = "**********"
命令:
send_mail("Test", "Test", "from_email@gmail.com", ["to_email@gmail.com"], fail_silently=False)
追踪:
^CTraceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/django/DjangoApps/ConnectedFeedback/Py3_ENV/lib/python3.4/site-packages/django/core/mail/__init__.py", line 61, in send_mail
return mail.send()
File "/home/django/DjangoApps/ConnectedFeedback/Py3_ENV/lib/python3.4/site-packages/django/core/mail/message.py", line 292, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/django/DjangoApps/ConnectedFeedback/Py3_ENV/lib/python3.4/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "/home/django/DjangoApps/ConnectedFeedback/Py3_ENV/lib/python3.4/site-packages/django/core/mail/backends/smtp.py", line 58, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python3.4/smtplib.py", line 242, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python3.4/smtplib.py", line 321, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.4/smtplib.py", line 292, in _get_socket
self.source_address)
File "/usr/lib/python3.4/socket.py", line 503, in create_connection
sock.connect(sa)
KeyboardInterrupt
我做错了什么?
编辑:我运行了telnet smtp.gmail.com 587
,它坐了大约5分钟,但最终连接成功了。