# Django Email SMTPAuthenticationError

**URL:** <https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104>\
**Category:** Using Django\
**Created:** [December 19, 2021, 8:21pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104 "2021-12-19T20:21:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![FLYAX](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/flyax/32/3422_2.png) [@FLYAX](https://forum.djangoproject.com/u/FLYAX)\
**Post date:** [December 19, 2021, 8:21pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/1 "2021-12-19T20:21:01Z")

</div>

Hey,

I have a code that sends an email, it worked about 2 weeks ago. Now when I want to send an email I get this error (535, b’5.7.8 Error: authentication failed: authentication failure ').

This is in my settings

```auto
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'cmail01.mailhost24.de.'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'noreply@divusx.com'
EMAIL_HOST_PASSWORD = 'passwordhere'

```

The funny thing is with this email no error appears but the emai is not sent as expected. If the receiver’s email is from gmail the email sents, but in office it doesnt.  
If I change the email from settings.py to another emails of mine like [info@divusx.com](mailto:info@divusx.com) the error from above appears. Something is really weird here.

This is how it should be:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/6/6b400f3dc4d9c1c67ca1919f0e0a286e686d8b1b.png)

---

<div class="post-metadata">

**Author:** ![FLYAX](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/flyax/32/3422_2.png) [@FLYAX](https://forum.djangoproject.com/u/FLYAX)\
**Post date:** [December 19, 2021, 8:22pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/2 "2021-12-19T20:22:45Z")

</div>

ah and this is my code for the email but it shouldnt be wrong because it worked 2 weeks ago and I didnt change anything.

```auto
    email = request.user.email
    send_mail(
        'DivusX - Test Request',
        'Test Text',
        '',
        [email],
        fail_silently=False,
)    

```

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [December 19, 2021, 10:07pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/3 "2021-12-19T22:07:39Z")

</div>

The image indicates the port should be 25, while your `EMAIL_PORT` setting is set to 587.

---

<div class="post-metadata">

**Author:** ![FLYAX](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/flyax/32/3422_2.png) [@FLYAX](https://forum.djangoproject.com/u/FLYAX)\
**Post date:** [December 19, 2021, 10:13pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/4 "2021-12-19T22:13:54Z")

</div>

yeah I already did that, the problem was that the email there was just delivered to a receiver who has a gmail adress. In outlook the mail doesnt deliver.

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [December 19, 2021, 10:34pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/5 "2021-12-19T22:34:26Z")

</div>

Is the call to send\_mail raising an error or is the email not being sent? If it’s the latter, I don’t think it’s a django issue.

---

<div class="post-metadata">

**Author:** ![FLYAX](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/flyax/32/3422_2.png) [@FLYAX](https://forum.djangoproject.com/u/FLYAX)\
**Post date:** [December 19, 2021, 10:36pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/6 "2021-12-19T22:36:21Z")

</div>

I think it’s sent it just doesnt gets delivered to my mail because if I try a gmail adress as receiver it works

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [December 19, 2021, 10:40pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/7 "2021-12-19T22:40:29Z")

</div>

Try checking your mail’s spam score. It sounds like outlook is marking it as spam and/or.not delivering it.

---

<div class="post-metadata">

**Author:** ![FLYAX](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/flyax/32/3422_2.png) [@FLYAX](https://forum.djangoproject.com/u/FLYAX)\
**Post date:** [December 20, 2021, 6:15pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/9 "2021-12-20T18:15:14Z")

</div>

if I change the port to 25 this error comes on my localhost

STARTTLS extension not supported by server.

---

<div class="post-metadata">

**Author:** ![dwtz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dwtz/32/6757_2.png) [@dwtz](https://forum.djangoproject.com/u/dwtz)\
**Post date:** [December 21, 2021, 2:54pm UTC](https://forum.djangoproject.com/t/django-email-smtpauthenticationerror/11104/10 "2021-12-21T14:54:30Z")

</div>

@FLYAX it sounds like you might be have an authentication issue (SPF, DKIM). Check those settings with your host and dns provider.

If you’re only doing local development at this point you can use the Console backend to view emails generated by your view.

[https://docs.djangoproject.com/en/4.0/topics/email/#console-backend](https://docs.djangoproject.com/en/4.0/topics/email/#console-backend)

As you move into production make sure you have the email authentication setup and tested.

I highly recommend using a transactional email service provider. These types of platforms offer email service geared towards notification type email delivery. There is a popular project called Anymail that makes it straightforward to use a transactional email service provider

> **[GitHub - anymail/django-anymail: Django email backends and webhooks for...](https://github.com/anymail/django-anymail)**
>
> Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more - GitHub - anymail/django-anymail: Django email backends and webhooks for Ama...
