简体   繁体   中英

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 = 'me@mytdl.de'
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?

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 = 'example@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM