Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending emails in Django with NameCheap email account

I set up an email account with NameCheap that I use with my Django app. Below is my email configuration based on information provided by NameCheap

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mail.privateemail.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASSWORD')
EMAIL_USE_SSL = True
DEFAULT_FROM_EMAIL = 'WebsiteTitle <[email protected]>'

Now when I use send_mail() django function (eg. after registration) it is like playing roulette - one time it works properly and sends out an email, another time it throws an error saying

SMTPServerDisconnected at /reset-password/ Connection unexpectedly closed

As if something was wrong with my email configuration.

Do you have any idea what might cause it or how to try to fix it or debug it? Is it more likely NameCheap or Django?

like image 773
Sygol Avatar asked Oct 19 '25 03:10

Sygol


1 Answers

hope you solved it otherwise for any other person who is stuck. FOR EMAIL HOST USE "smtp.privateemail.com", the other parameters are ok.

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.privateemail.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASSWORD')
EMAIL_USE_SSL = True
DEFAULT_FROM_EMAIL = 'WebsiteTitle <[email protected]>'
like image 91
Kevin Owino Avatar answered Oct 20 '25 17:10

Kevin Owino