Errno 111 Connection refused Django REST on CPanel - django

I'm using gmail smtp, and I get this error:
[Errno 111] Connection refused
I'm getting this on cpanel shared hosting, but it's working perfectly fine on local.
Here's my Django configuration:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = config("EMAIL_HOST")
EMAIL_PORT = 587
EMAIL_HOST_USER = config("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = config("EMAIL_HOST_PASSWORD")
EMAIL_FROM = config("EMAIL_FROM")
DEFAULT_FROM_EMAIL = 'email#gmail.com'
SERVER_EMAIL = 'email#gmail.com'
EMAIL_BCC = ""
EMAIL_USE_SSL = False
I contacted my WHM and told them to disable smtp restrictions. Their firewall is also not blocking gmail's smtp and the required ports are also open.
Please help me.

I fixed this by telling my WHM to add my cPanel username on SMTP_ALLOWUSER as per: SMTP ERROR: Failed to connect to server: Connection refused (111) with Office365

Related

gmail smtp not connecting

so I'm trying to set up my smtp for mail delivery and I decided to use gmail. I've seen the new update concerning the restrictions placed on less secure apps so I went ahead to get A 2FA password but still I'm getting an error.
my settings.py
#smtp settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.getenv('EMAIL_USER')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASS')
The error that it's throwing is:
TimeoutError at /Shipping/Ship/
[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Any help please?

"SMTP AUTH extension not supported by server" error while trying to send email though django app using gmail

I am trying to send a mail from my django application through gmail and i get the error saying "SMTP AUTH extension not supported by server."
I have added
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USER_TLS = True
EMAIL_HOST_USER = 'abc#gmail.com'
EMAIL_HOST_PASSWORD = 'random'
in my setting.py.
Can anyone please help me figure out the solution?
EMAIL_USER_TLS IS WRONG.
Use EMAIL_USE_TLS instead (fix typing error).
Gmail offers SMTP AUTH on port 587 only after STARTTLS.
Without STARTTLS (turning on encryption) SMTP AUTH is unavailable.

How to Send an Email Django

Previously, I was using SendGrid to serve emails using Django's SMTP backend, which worked perfectly fine. However, now I would like my project to use Microsoft Exchange. When I updated my SMTP configuration in settings.py, upon the submission of some form to be emailed, the page timesout when trying to reach the server: TimeoutError: [Errno 60] Operation timed out.
settings.py
# E-Mail
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.microsoft365.com'
EMAIL_HOST_USER = 'username#domain.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
views.py
# Send email
send_mail('!!New Mail!! ', content, 'noreply#domain.com', ['username#domain.com'], fail_silently=False)
I solved my problem when I used the correct SMTP port (25, 465, 587) for my particular mail server.
settings.py
EMAIL_PORT = 25

How to send report mail like Google

I have a web using Django framework run in localhost, I want web send email automatically to a email address, but I have a trouble in config EMAIL_HOST, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD and EMAIL_PORT in settings.py
this is settings.py I configured:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
EMAIL_HOST = 'localhost'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 25
How can I fix to send email?
Your project runs on localhost but your mailserver runs on google
try this
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = EMAIL_HOST_PASSWORD
You will need to set up Gmail, say with an application password.
See the google guide here and for app passwords here
If you connect using SSL or TLS, you can send mail to anyone with
smtp.gmail.com.
Note: Before you start the configuration, we recommend you set up App
passwords for the the desired account. Learn more at Sign in using App
Passwords and Manage a user's security settings.
Connect to smtp.gmail.com on port 465, if you’re using SSL. (Connect
on port 587 if you’re using TLS.) Sign in with a Google username and
password for authentication to connect with SSL or TLS. Ensure that
the username you use has cleared the CAPTCHA word verification test
that appears when you first sign in.
But if you are using gmail then you should look into the gmail api because then you can deal with inbound mails and you can use labels etc to manage the mails, it works well eventually once you get your head around oAuth etc. I know you didn't ask about that, but I personally find it useful.

SMTP connection timeout in Sentry

I'm using Sentry to monitor a Django app. I copied the following (correct and tested) email settings from the Django app to my Sentry config file:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mail.privateemail.com'
EMAIL_HOST_USER = 'info#ookmijnbedrijf.nl'
EMAIL_HOST_PASSWORD = '***'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_USE_TLS = False
SERVER_EMAIL = EMAIL_HOST_USER
Everything looks right on the SMTP Settings page, but when I try to send a test email I get this:
Connection unexpectedly closed: timed out
My Django app is sending emails correctly with these exact settings. What am I doing wrong?
Turns out Sentry only supports SMTP with TLS (not SSL). Made an issue about this.