不使用django 1.9发送电子邮件

时间:2016-02-08 00:40:54

标签: python django python-3.x

我一直在尝试使用我正在处理的项目来处理电子邮件,我相信它已正确配置,这里是我的settings.py,我正在运行的命令,以及我停止时获得的回溯

电子邮件配置:

    #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分钟,但最终连接了

1 个答案:

答案 0 :(得分:1)

所以最终只是谷歌帐户安全问题。谷歌阻止了尝试的尝试。