我试图通过django发送邮件,.This是我写的代码
from django.shortcuts import render
from django.http import HttpResponse
from django.core.mail import send_mail
def function(request):
send_mail('cheking',
'cheking django is sending mail or not',
'nithinjith40@gmail.com',
['ravisarath64@gmasil.com'],
fail_silently=False)
return render(request,'message.html')但它显示了这个错误
Internal Server Error: /
Traceback (most recent call last):
File "/home/expert/project _jango/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/expert/project _jango/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/expert/project _jango/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/expert/project _jango/myproject/webapp/views.py", line 11, in function
fail_silently=False)
File "/home/expert/project _jango/venv/lib/python3.5/site-packages/django/core/mail/__init__.py", line 60, in send_mail
return mail.send()
File "/home/expert/project _jango/venv/lib/python3.5/site-packages/django/core/mail/message.py", line 291, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/expert/project _jango/venv/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 103, in send_messages
new_conn_created = self.open()
File "/home/expert/project _jango/venv/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 70, in open
self.connection.login(self.username, self.password)
File "/usr/lib/python3.5/smtplib.py", line 729, in login
raise last_exceptio
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials d65sm27731624pfa.159 - gsmtp')如何解决这个错误?'I启用不那么安全的应用程序访问‘然后显示相同的错误--请随意询问我在注释部分中省略的代码行的细节
发布于 2019-12-24 14:52:26
这不是django错误,它看起来像是gmail问题。确保您可以通过gmail网络阅读和发送邮件,并遵循gmail故障排除步骤。不过,我建议您搬到App密码。
https://stackoverflow.com/questions/59466630
复制相似问题