0

Django sendmail is not working, I'm getting this error:

(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials q13sm252028qtx.80 - gsmtp')

There are similar question on S.O.,like this. everyone taking about "allow less secure apps", but I already turn that option ON. My auth details are correct, I had tried with two different accounts. Two step verification is disabled.

settings.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'myemail'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_USE_TLS = True

views.py

def sendmail(email,token):
    subject = 'Verify Email'
    message = 'Hello User please activate your account by click on this link '+'http://mywebsite.pythonanywhere.com/email/verify/'+token
    from_email = 'praveexxxxxxxxxxx@gmail.com'
    recipient_list = [email]
    send_mail(subject=subject,message=message,from_email=from_email,recipient_list=recipient_list)

def signup(request):
    token = generatedtoken
    email = someoneemail@gmail.com
    sendmail(email,token)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Praveen Yadav
  • 443
  • 4
  • 16
  • 2
    Take a look at app-specific passwords https://help.pythonanywhere.com/pages/GmailAppSpecificPasswords – Filip Oct 27 '21 at 09:41
  • Did you try logging in from a browser using same authentication credentials?, Try logging in from an incognito window. – Ruby Dec 08 '21 at 18:39

0 Answers0