Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STARTTLS extension not supported by server - Getting this error when trying to send an email through Django and a private email address

I registered a domain and a private email using namecheap.com. I am trying to send an email from this private email. However, I get the error in the title.

In my settings.py, I have these settings:

EMAIL_HOST = 'mail.privateemail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'my password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

And I am trying to send the email through a view:

send_mail(
    'Subject here',
    'Here is the message.',
    '[email protected]',
    ['[email protected]'],
    fail_silently=False,
)

However, I get this error:

SMTPException at /
STARTTLS extension not supported by server.

Any idea why? Any help is appreciated.

EDIT

After changing the EMAIL_USE_TLS to False, and also removing it to check both separately, I get this error now:

SMTP AUTH extension not supported by server.

Any idea why? Thanks!

like image 531
darkhorse Avatar asked Jun 30 '16 23:06

darkhorse


3 Answers

your server mail.privateemail.com does not know what is STARTTLS SMTP Commnad is

this may happen in two cases:

  1. your server (mail.privateemail.com) do not support secure communication at all and you need to use plain, non-encrypted communication.
  2. you are trying to connect to the port that is already using SSL as the communication, then STARTTLS to upgrade connection to secure make no sense whatsoever.
  3. your server is configured improperly and ignores STARTTLS on submission port (587).

Judging, that you are connecting to port 587 which should provide plain communication - it's either 1 or 3.

If you want this just work, remove EMAIL_USE_TLS = True or set it to False, otherwise - SMTP server configuration should be fixed.

like image 174
Jerzyk Avatar answered Nov 12 '22 06:11

Jerzyk


You may try SSL instead of TLS by making following changes in settings.py

EMAIL_USE_SSL = True
EMAIL_PORT = 465

hope that helps

like image 36
Mukesh M Goswami Avatar answered Nov 12 '22 06:11

Mukesh M Goswami


Either setup TLS on your mail server or use EMAIL_USE_TLS = False.

like image 1
kichik Avatar answered Nov 12 '22 05:11

kichik