Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django SMTP Error: authentication failed: authentication failure

I set up django email backend following way:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# Host for sending e-mail.
EMAIL_HOST = 'mytdl.de'

# Port for sending e-mail.
EMAIL_PORT = 25

# Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')

But sending emails with django-allauth will return following error:

(535, b'5.7.8 Error: authentication failed: authentication failure')

Testing the the settings with

 telnet  mytdl.de 25

or Thunderbird as email client works fine.

2.7.0 Authentication successful

But Django / SMTP stills throws that error. Django also tries to

AUTH CRAM-MD5

and not

AUTH LOGIN

any ideas?

like image 365
isnochys Avatar asked Oct 29 '22 04:10

isnochys


1 Answers

If your email host is gmail then you can fix it with these simple steps:

  1. Login to your gmail account (The one you are using in your Django application for sending mails ).
  2. Then select Account from google apps or click here.
  3. On your control panel click on Apps with account access under Sign-in & security.
  4. Then scroll down and enable Allow less secure apps

Also maintain your settings variables in this order:

settings.py

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587
like image 125
Ahtisham Avatar answered Nov 15 '22 07:11

Ahtisham