<bdo id='dg572'></bdo><ul id='dg572'></ul>

<small id='dg572'></small><noframes id='dg572'>

<i id='dg572'><tr id='dg572'><dt id='dg572'><q id='dg572'><span id='dg572'><b id='dg572'><form id='dg572'><ins id='dg572'></ins><ul id='dg572'></ul><sub id='dg572'></sub></form><legend id='dg572'></legend><bdo id='dg572'><pre id='dg572'><center id='dg572'></center></pre></bdo></b><th id='dg572'></th></span></q></dt></tr></i><div id='dg572'><tfoot id='dg572'></tfoot><dl id='dg572'><fieldset id='dg572'></fieldset></dl></div>
<legend id='dg572'><style id='dg572'><dir id='dg572'><q id='dg572'></q></dir></style></legend>
      <tfoot id='dg572'></tfoot>

      无法将 Django 设置为与 smtp.gmail.com 一起使用

      时间:2023-07-03

        <i id='JpTEo'><tr id='JpTEo'><dt id='JpTEo'><q id='JpTEo'><span id='JpTEo'><b id='JpTEo'><form id='JpTEo'><ins id='JpTEo'></ins><ul id='JpTEo'></ul><sub id='JpTEo'></sub></form><legend id='JpTEo'></legend><bdo id='JpTEo'><pre id='JpTEo'><center id='JpTEo'></center></pre></bdo></b><th id='JpTEo'></th></span></q></dt></tr></i><div id='JpTEo'><tfoot id='JpTEo'></tfoot><dl id='JpTEo'><fieldset id='JpTEo'></fieldset></dl></div>
      • <legend id='JpTEo'><style id='JpTEo'><dir id='JpTEo'><q id='JpTEo'></q></dir></style></legend>

              <bdo id='JpTEo'></bdo><ul id='JpTEo'></ul>

                  <tbody id='JpTEo'></tbody>

                <small id='JpTEo'></small><noframes id='JpTEo'>

              1. <tfoot id='JpTEo'></tfoot>
              2. 本文介绍了无法将 Django 设置为与 smtp.gmail.com 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我一直试图让 django 与 gmail 的 smtp 服务器一起发送邮件,但我总是得到这个回溯.任何帮助将不胜感激.

                --settings.py -----

                EMAIL_HOST = 'smtp.gmail.com'EMAIL_HOST_USER = 'user@gmail.com'EMAIL_HOST_PASSWORD = '你的密码'电子邮件端口 = 587EMAIL_USE_TLS = 真

                ---- python shell -----

                <块引用><块引用>

                从 django.core.mail 导入 EmailMessage

                email = EmailMessage('Mail Test', 'This is a test', to=['somemail@something.com'])

                email.send()

                Traceback(最近一次调用最后一次):文件<console>",第 1 行,在 <module>文件/home/fiodorovich/Envs/fdict/lib/python2.7/site-packages/django/core/mail/message.py",第 251 行,在发送中return self.get_connection(fail_silently).send_messages([self])文件/home/fiodorovich/Envs/fdict/lib/python2.7/site-packages/django/core/mail/backends/smtp.py",第 86 行,在 send_messages发送 = self._send(消息)_send 中的文件/home/fiodorovich/Envs/fdict/lib/python2.7/site-packages/django/core/mail/backends/smtp.py",第 104 行email_message.message().as_string())文件/usr/local/lib/python2.7/smtplib.py",第 701 行,在 sendmail 中raise SMTPSenderRefused(code, resp, from_addr)SMTPSenderRefused: (530, '5.7.0 必须先发出 STARTTLS 命令.z15sm10449686anl.15', 'webmaster@localhost')

                进行 unni 建议的修改时出现新错误.shell 不会执行,我收到此错误消息

                **EMAIL_HOST_USER = 'some.account@gmail.com'**^SyntaxError:无效的语法

                解决方案

                我最近设置了这个,settings.py 配置略有不同.

                移动:

                EMAIL_USE_TLS = True

                到 EMAIL_HOST 上方

                添加:

                DEFAULT_FROM_EMAIL = 'user@gmail.com'SERVER_EMAIL = 'user@gmail.com'

                I've been trying to get django to work with gmail's smtp server to send mails but I always get this traceback. Any help will be most appreciated.

                ----- settings.py -----

                EMAIL_HOST = 'smtp.gmail.com'
                
                EMAIL_HOST_USER = 'user@gmail.com'
                
                EMAIL_HOST_PASSWORD = 'your-password'
                
                EMAIL_PORT = 587
                
                EMAIL_USE_TLS = True
                

                ---- python shell -----

                from django.core.mail import EmailMessage

                email = EmailMessage('Mail Test', 'This is a test', to=['somemail@something.com'])

                email.send()

                Traceback (most recent call last):
                File "<console>", line 1, in <module>
                File "/home/fiodorovich/Envs/fdict/lib/python2.7/site-packages/django/core/mail/message.py", line 251, in send
                return self.get_connection(fail_silently).send_messages([self])
                File "/home/fiodorovich/Envs/fdict/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 86, in send_messages
                sent = self._send(message)
                File "/home/fiodorovich/Envs/fdict/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 104, in _send
                email_message.message().as_string())
                File "/usr/local/lib/python2.7/smtplib.py", line 701, in sendmail
                raise SMTPSenderRefused(code, resp, from_addr)
                SMTPSenderRefused: (530, '5.7.0 Must issue a STARTTLS command first. z15sm10449686anl.15', 'webmaster@localhost')
                

                Edit: New errors when made the modification suggested by unni. The shell won't execute and I'm getting this error message

                **EMAIL_HOST_USER  = 'some.account@gmail.com'**
                 ^
                SyntaxError: invalid syntax
                

                解决方案

                I have recently set this up and had a slightly different settings.py config.

                Move:

                EMAIL_USE_TLS = True 
                

                to the top above EMAIL_HOST

                Add:

                DEFAULT_FROM_EMAIL = 'user@gmail.com'
                SERVER_EMAIL = 'user@gmail.com'
                

                这篇关于无法将 Django 设置为与 smtp.gmail.com 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:通过 smtplib 发送电子邮件时如何在电子邮件内容中添加 href 链接 下一篇:Python 不向多个地址发送电子邮件

                相关文章

                    <bdo id='y6P3j'></bdo><ul id='y6P3j'></ul>

                1. <tfoot id='y6P3j'></tfoot>

                  <i id='y6P3j'><tr id='y6P3j'><dt id='y6P3j'><q id='y6P3j'><span id='y6P3j'><b id='y6P3j'><form id='y6P3j'><ins id='y6P3j'></ins><ul id='y6P3j'></ul><sub id='y6P3j'></sub></form><legend id='y6P3j'></legend><bdo id='y6P3j'><pre id='y6P3j'><center id='y6P3j'></center></pre></bdo></b><th id='y6P3j'></th></span></q></dt></tr></i><div id='y6P3j'><tfoot id='y6P3j'></tfoot><dl id='y6P3j'><fieldset id='y6P3j'></fieldset></dl></div>

                    <small id='y6P3j'></small><noframes id='y6P3j'>

                  1. <legend id='y6P3j'><style id='y6P3j'><dir id='y6P3j'><q id='y6P3j'></q></dir></style></legend>