Hi,

I’m getting this error when I try to send an email via my server on Django.

‘Failed to send email: SMTP AUTH extension not supported by server.’

The settings are all in order, I have set EMAIL_USE_TLS = True but the issue still persists?

Is there anyone that has encountered this issue before?

Any assistance will be appreaciated.

  • Thanks Doc. I did manage to find a solution. send_mail leverages smtplib, but only assumes user use LOGI AUTH after ehlo and STARTTLS. So I created a custom backend that uses PLAIN AUTH Method. I’ll leave the Code here if anybody needs it. Thanks.

    from django.core.mail.backends.smtp import EmailBackend
    import base64

    class PlainAuthEmailBackend(EmailBackend):
    def _send(self, email_message):

    Override the _send method to use PLAIN authentication

    if not self.connection:
    self.open()
    if not self.connection:
    return False

        # Encode credentials in PLAIN format
        auth_string = f'\0{self.username}\0{self.password}'
        auth_string_encoded = base64.b64encode(auth_string.encode('utf-8')).decode('utf-8')
        print(f"Auth Creds: {auth_string_encoded}")
        # Send AUTH PLAIN command
        self.connection.docmd("AUTH PLAIN", auth_string_encoded)
    
        # Send the email
        return super()._send(email_message)

    Thanks Doc. I did manage to find a solution. send_mail leverages smtplib, but only assumes user use LOGI AUTH after ehlo and STARTTLS. So I created a custom backend that uses PLAIN AUTH Method. I’ll leave the Code here if anybody needs it. Thanks.

    from django.core.mail.backends.smtp import EmailBackend
    import base64

    class PlainAuthEmailBackend(EmailBackend):
    def _send(self, email_message):

    Override the _send method to use PLAIN authentication

    if not self.connection:
    self.open()
    if not self.connection:
    return False

        # Encode credentials in PLAIN format
        auth_string = f'\0{self.username}\0{self.password}'
        auth_string_encoded = base64.b64encode(auth_string.encode('utf-8')).decode('utf-8')
        print(f"Auth Creds: {auth_string_encoded}")
        # Send AUTH PLAIN command
        self.connection.docmd("AUTH PLAIN", auth_string_encoded)
    
        # Send the email
        return super()._send(email_message)
  • DocFraggle

    • Community Hero
    Moolevel 278

I guess you’re using port 25, but for auth you have to use 587

Have something to say?

Join the community by quickly registering to participate in this discussion. We'd like to see you joining our great moo-community!

I still get the same message with Port 587, error
:
“Failed to send email: SMTP AUTH extension not supported by server.”

  • DocFraggle

    • Community Hero
    Moolevel 278

Hmm, check this thread then:

Stack Overflow Icon Trouble with Django sending email though smtp.gmail.com

They’re talking about

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

I can’t help you otherwise, I don’t use Django

Thanks Doc. I did manage to find a solution. send_mail leverages smtplib, but only assumes user use LOGI AUTH after ehlo and STARTTLS. So I created a custom backend that uses PLAIN AUTH Method. I’ll leave the Code here if anybody needs it. Thanks.

from django.core.mail.backends.smtp import EmailBackend
import base64

class PlainAuthEmailBackend(EmailBackend):
def _send(self, email_message):

Override the _send method to use PLAIN authentication

if not self.connection:
self.open()
if not self.connection:
return False

    # Encode credentials in PLAIN format
    auth_string = f'\0{self.username}\0{self.password}'
    auth_string_encoded = base64.b64encode(auth_string.encode('utf-8')).decode('utf-8')
    print(f"Auth Creds: {auth_string_encoded}")
    # Send AUTH PLAIN command
    self.connection.docmd("AUTH PLAIN", auth_string_encoded)

    # Send the email
    return super()._send(email_message)

Thanks Doc. I did manage to find a solution. send_mail leverages smtplib, but only assumes user use LOGI AUTH after ehlo and STARTTLS. So I created a custom backend that uses PLAIN AUTH Method. I’ll leave the Code here if anybody needs it. Thanks.

from django.core.mail.backends.smtp import EmailBackend
import base64

class PlainAuthEmailBackend(EmailBackend):
def _send(self, email_message):

Override the _send method to use PLAIN authentication

if not self.connection:
self.open()
if not self.connection:
return False

    # Encode credentials in PLAIN format
    auth_string = f'\0{self.username}\0{self.password}'
    auth_string_encoded = base64.b64encode(auth_string.encode('utf-8')).decode('utf-8')
    print(f"Auth Creds: {auth_string_encoded}")
    # Send AUTH PLAIN command
    self.connection.docmd("AUTH PLAIN", auth_string_encoded)

    # Send the email
    return super()._send(email_message)
No one is typing