Django smtp соединение с office 365 Outlook

Мы получаем следующую ошибку при использовании SMTP-сервера Office 365 для отправки писем из приложения Django.

    Traceback (most recent call last):
  File "/home/app/views.py", line 598, in send_mail
    django.core.mail.send_mail(
  File "/usr/local/lib/python3.8/site-packages/django/core/mail/__init__.py", line 61, in send_mail
    return mail.send()
  File "/usr/local/lib/python3.8/site-packages/django/core/mail/message.py", line 284, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python3.8/site-packages/django/core/mail/backends/smtp.py", line 69, in open
    self.connection.login(self.username, self.password)
  File "/usr/local/lib/python3.8/smtplib.py", line 732, in login
    raise last_exception
  File "/usr/local/lib/python3.8/smtplib.py", line 721, in login
    (code, resp) = self.auth(
  File "/usr/local/lib/python3.8/smtplib.py", line 644, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Mailbox. Visit https://aka.ms/smtp_auth_disabled for more information. [PN2PR01CA0172.INDPRD01.PROD.OUTLOOK.COM]')

следующую настройку сделал в Django setting.py

EMAIL_HOST=smtp.office365.com
EMAIL_USE_TLS=True
EMAIL_PORT=587 # also tried port 25
EMAIL_USER=test@example.com
EMAIL_PASSWORD=test

And following the steps for setting up the Outlook 365 SMTP relay account (Steps) and also checked the Authenticated SMTP for the admin account. Is I am doing anything wrong or missing anything?

Будем признательны за любую помощь, спасибо :)

Вернуться на верх