am soo frustrated at this error. for some days i have tried all possible troubleshoots(eg turning on less secure apps,2FA, unlocking captcha) still its firing the error. I will highly value your help. below is my code
Traceback
Environment:
Request Method: POST
Request URL: http://localhost:8000/
Django Version: 3.0.9
Python Version: 3.8.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'shield_sec']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/apple/projects/Django/ingabo_sec/shield_sec/views.py", line 17, in contact
send_mail (
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/mail/__init__.py", line 60, in send_mail
return mail.send()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/mail/message.py", line 284, in send
return self.get_connection(fail_silently).send_messages([self])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
new_conn_created = self.open()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 69, in open
self.connection.login(self.username, self.password)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/smtplib.py", line 734, in login
raise last_exception
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/smtplib.py", line 723, in login
(code, resp) = self.auth(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/smtplib.py", line 646, in auth
raise SMTPAuthenticationError(code, resp)
Exception Type: SMTPAuthenticationError at /
Exception Value: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials h20sm1909465lfc.239 - gsmtp')
Settings.py
# Email_settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'shieldseclab@gmail.com'
EMAIL_HOST_PASSWORD = '******'
EMAIL_USE_TLS = True
#ACCOUNT_EMAIL_VERIFICATION = 'none'
#DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
#EMAIL_USE_SSL = True
Views.py
def contact (request):
if request.method == "POST":
sender_name = request.POST.get('sender-name',False)
sender_number = request.POST.get('sender-number',False)
sender_email = request.POST.get('sender-email',False)
sender_subject = request.POST.get('sender-subject',False)
message = request.POST.get('message',False)
send_mail (
sender_name,
sender_number,
sender_email,
['shieldseclab@gmail.com'],
sender_subject,
message,
)
return render (request,'shield_sec/contact.html', {'sender_name': sender_name})
else:
return render (request,'shield_sec/contact.html', {})