Email is not sending in django after deploy in Cpanel - django

I just deploy a Django web app in Cpanel. But SMTP email is not working in Cpanel. It works only on my local machine. I don't have much knowledge about Cpanel.
Here is my code for setting.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'my gmail'
EMAIL_HOST_PASSWORD = 'password'

solved!! changed EMAIL_HOST_USER to cpnael hosting email.

Related

Django multiple SMTP accounts

Here are the Django simple SMTP backend settings for just 1 email account
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = "mail.mysmtpserver.somewhere"
EMAIL_PORT = 587
EMAIL_HOST_USER = "my#login"
EMAIL_HOST_PASSWORD = "mypassword"
EMAIL_USE_TLS = True
How is it possible to use 2 or more email accounts on the same server instead of one?
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = "mail.mysmtpserver.somewhere"
EMAIL_PORT =587
EMAIL_HOST_USER = "my#login2"
EMAIL_HOST_PASSWORD = "mypassword2"
EMAIL_USE_TLS = True
I just need to send different emails based on the subject by different email account.
I checked the Django documentation but there was nothing

How to configure Django Email Back-end Settings to send email via RoundCube Webmail in production

During development, I have been using Gmail SMTP to send emails from my Django app. The Gmail settings are (settings.py):
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'xxxx#gmail.com'
EMAIL_HOST_PASSWORD = 'xxxxxxxxx'
However, during production, I need to change to RoundCube webmail client to allow my project to use a custom email address that matches the domain name. I have tried the following settings and many others but none of them is working. I know this is simple, but this is my first project and I don't know whether there is something I am missing.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mydomain.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 465
EMAIL_HOST_USER = 'accounts#mydomain.com'
EMAIL_HOST_PASSWORD = 'xxxxxxxxx'

django-registration sending activation and reset emails

I am trying to send activation and reset email in Django, but I am facing some challenges.
setting.py
EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST ='smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS =True
EMAIL_HOST_USER ='email#gmail.com'
EMAIL_HOST_PASSWORD ='gmailpasword'
EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = ‘mail.mysite.com’
DEFAULT_FROM_EMAIL = 'noreply#mysite.com'
EMAIL_HOST_USER = 'noreply#mysite.com'
EMAIL_HOST_PASSWORD = 'my pass'
EMAIL_USE_TLS = True
EMAIL_PORT = port
The first configuration is with Gmail which work fine in development but in production (shared Linux server) it does not work at all. The second configuration with an email I set up on
webmail (cPanel) which is not working in either development or production.

What is EMAIL_PORT for protonmail.com mail service?

I tried to use https://protonmail.com email service for my django app to send notification emails. I googled and found that protonmail SMTPis 1026 and protonmail IMAP is 1143.
When I use gmail service it works fine.
My settings.py
EMAIL_HOST = 'smtp.protonmail.com'
EMAIL_HOST_USER = 'username#protonmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 1026
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'apps', 'emails')
The ProtonMail Bridge says the email port should be 1025. I attached a screenshot of my SMTP settings.

Sending email from Django via hosted SMTP

How do you send email from Django using a hosted SMTP account (specially on Namecheap)?
I thought this would be straight forward, and simply a matter of filling out the standard EMAIL_* fields in my settings.py.
However, after entering my credentials in both my settings.py and Thunderbird, Thunderbird can download and send email, but Django times out with the error "SMTPServerDisconnected: Connection unexpectedly closed" when attempting to do the same.
My working settings in Thunderbird for my outgoing server (SMTP):
Server Name: oxmail.registrar-servers.com
Port: 465
User Name: myuser#mydomain.com
Authentication method: Normal password
Connection Security: SSL/TLS
My non-working settings in my Django settings.py:
EMAIL_HOST = 'oxmail.registrar-servers.com'
EMAIL_HOST_USER = 'myuser#mydomain.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 465
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
Aren't these settings identical? What am I doing wrong? Why does one work while the other fails?
Turns out the problem was that the default SMTP backend in Django does not support SSL, and my SMTP host required it (not just TLS). Fortunately, I found a dirt-simple SSL backend, added EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend' to my settings.py and everything just worked.
The settings below:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'mail.yourdomain.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'no-reply#yourdomain.com'
EMAIL_HOST_PASSWORD = 'password'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
worked for me.
My django version I tested with is 1.8.8.