I currently am using django-password-reset to assist users when they forget a password. Everything worked just fine while in development but now I am having issues setting up the email backend on my production server.
When a user enters their username or email into the password reset form and push the 'Recover Password' button that would normally trigger the password-reset email, the page starts to load infinitely. I am attempting to use a gmail account as my smtp server. I am assuming that there is some sort of issue with my settings.py file.
settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'example#gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'example#gmail.com'
If you have any idea what is wrong with my configuration or any other ways to set up my email backend advice would be greatly appreciated! Thanks
This works locally at least.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'something#gmail.com'
EMAIL_HOST_PASSWORD = 'something'
EMAIL_USE_TLS = True
Related
I am using cpanel email on gmail. But when sending mails through Django EmailAlternatives, the mail being sent is reported as dangerous. How do I make it safe, or if I am using PORT 465 and HOST as smtp.gmail.com, it is not working. Below given are my EMAIL Details.
WSGI_APPLICATION = 'backend.wsgi.application'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mail.my_dot_in_domain'
EMAIL_HOST_USER = 'my_email'
EMAIL_HOST_PASSWORD = 'my_password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
Screenshot to explain what mail says and all the details
Actually i am creating a registration form using django and when user will submit it he will get successful registration mail but it will give me error SMTPNotSupported extension server.
my settings.py file
EMAIL_HOST = 'smpt.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = myusername
EMAIL_HOST_PASSWORD = my password
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend
I am sharing my error photo with you all.
I tried to configure sending email on registration using gmail server and i get these error:
(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError u2sm3847520edr.70 - gsmtp', 'webmaster#localhost').
These are my configurations in settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
I don't think you configured the environment variables.
$ export EMAIL_HOST_USER ="yournotsosecretemail"
$ export EMAIL_HOST_PASSWORD ="yourverysecretpassword"
$ python manage.py runserver
I guess that there are other ways to store environment variables, this is just one way. If you want some debugging help, add some print statements after the configuration.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
print('Email:', EMAIL_HOST_USER)
print('Password:, 'EMAIL_HOST_PASSWORD)
I'm trying to send email with django. Here's my settings.py file.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'mymail#gmail.com'
EMAIL_HOST_PASSWORD = 'mailpassword'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'mymail#gmail.com'
I've also enabled access to less secure apps in the gmail settings.
On the production server whenever I try to send an email, it's raising an error in the command line upstream prematurely closed connection while reading response header from upstream.
On webpage it's showing 502 Bad Gateway error.
How can we solve this issue? Thank You . . .
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 = 'contact#mysite.com'
EMAIL_HOST_PASSWORD = 'my password'
EMAIL_PORT = 465
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.',
'contact#mysite.com',
['myname#gmail.com'],
fail_silently=False,
)
However, I get this error when I load the view, and try to send the email:
SMTPServerDisconnected at /
Connection unexpectedly closed: [Errno 54] Connection reset by peer
What am I doing wrong? And how can I fix this? Thanks.
EDIT
After changing the port to 587, I get the following error:
SMTPException at /
STARTTLS extension not supported by server.
Any idea why? Any help is appreciated.
EMAIL_HOST = os.getenv("EMAIL_HOST")
EMAIL_PORT = os.getenv("EMAIL_PORT")
EMAIL_USE_SSL = os.getenv("EMAIL_USE_SSL")
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
using SSL instead of TLS solved my issue.
You are using EMAIL_USE_TLS = True it will not work for hosted domain email.
Use EMAIL_USE_SSL = True
here is full configs
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_SSL = True
EMAIL_HOST = 'mail.<domain>.com'
EMAIL_HOST_USER = '<some_name>#<domain>.com'
EMAIL_HOST_PASSWORD = '<user_password>'
EMAIL_PORT = 465
Try using port 587 (TLS) instead of 465 (SSL): https://www.namecheap.com/support/knowledgebase/article.aspx/9183/2175/email-account-setup-in-microsoft-outlook-20072010-smtpimappop3
I also faced this same issue on Namecheap but the Namecheap support staff didn't solve this problem. I got an answer on StackOverflow.
that error show because we used EMAIL_PORT = 465.
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
set 587 port no. definitely you resolve this error. if you using 465 then change this EMAIL_USE_SSL = True and EMAIL_USE_TLS = False.