Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django email configuration with Bluehost email server

I am new to Bluehost and Django and I am trying to setup a "password reset via email" function on my Bluehost server with Django. I've tried different combinations on setting the host and port number but for some reason it never worked. So here's what I had: (I am currently only working on my local computer.)

On Bluehost website where I can configure my email account, it lists:

Manual Settings

  • Mail Server Username: admin+my_host.com
  • Incoming Mail Server: mail.my_host.com
  • Incoming Mail Server: (SSL) box664.bluehost.com
  • Outgoing Mail Server: mail.my_host.com (server requires authentication) port 26
  • Outgoing Mail Server: (SSL) box664.bluehost.com (server requires authentication) port 465
  • Supported Incoming Mail Protocols: POP3, POP3S (SSL/TLS), IMAP, IMAPS (SSL/TLS)
  • Supported Outgoing Mail Protocols: SMTP, SMTPS (SSL/TLS)

In settings.py I have the emails configured as: (I will list two combinations and the corresponding error message)

combination 1

DEFAULT_FROM_EMAIL  = 'admin@my_host.com'
SERVER_EMAIL = 'admin@my_host.com'
EMAIL_USE_TLS   = False
EMAIL_HOST      = 'box664.bluehost.com'
EMAIL_HOST_PASSWORD = 'my_email_password'
EMAIL_HOST_USER = 'admin+my_host.com'
EMAIL_PORT      = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

error message: Exception Value: Connection unexpectedly closed

combination 2

DEFAULT_FROM_EMAIL  = 'admin@my_host.com'
SERVER_EMAIL = 'admin@my_host.com'
EMAIL_USE_TLS   = True
EMAIL_HOST      = 'mail.my_host.com'
EMAIL_HOST_PASSWORD = 'my_email_password'
EMAIL_HOST_USER = 'admin+my_host.com'
EMAIL_PORT      = 26
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

error message: Exception Value: (535, 'Incorrect authentication data')


Could anyone give me some suggestions where I did wrong? Any help is appreciated.

like image 844
Yue Y Avatar asked Oct 02 '22 12:10

Yue Y


People also ask

Does Bluehost have an SMTP server?

Bluehost supports IMAP / SMTP That means you don't have to use Bluehost webmail interface! You can check your emails using other email programs (like Mailbird, Microsoft Outlook or Mozilla Thunderbird). Using desktop email programs will make you more productive and your email will always be available, even offline.

How does django send email?

Sending Emails with the Django ShellWe import the Django send_mail function. Then we import the settings object which contains all the global settings and the per-site settings (those inside the settings.py file). Finally, we pass all the needed arguments to the send_mail function.

What is django mailer?

django-mailer is a reusable Django app for queuing the sending of email. It works by storing email in the database for later sending.


2 Answers

The following settings:

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

worked for me. My django version I tested with is 1.8.8. Bluehost smtp settings details are explained here.

like image 136
javed Avatar answered Oct 09 '22 03:10

javed


I exactly dunno what the problem is, but I have faced the same problem. I think it has something to do with SMTP/SSL. So what I used this: https://github.com/perenecabuto/django-sendmail-backend

Then I used this configuration in settings.py:

    EMAIL_USE_SSL = False
    EMAIL_USE_TLS= False
    EMAIL_HOST = 'box###.bluehost.com'
    EMAIL_PORT = 465
    EMAIL_HOST_USER = '[email protected]'
    EMAIL_HOST_PASSWORD = 'password'

Hope it helps.

like image 29
ruddra Avatar answered Oct 09 '22 04:10

ruddra