smtpauthenticationerror 534 django python registration - python

I know that this question was asked a lot o times, but I have a little different situation. I am deploying my django app with implemented django-registration-redux on heroku. The registration works fine on local machine, but it gives smtpauthenticationerror 534 on heroku.
I ALLOWED less secure apps on my google account, but the error persist.
I clicked on DisplayUnlockCaptcha the button Continue- still doesn't work.
Here is the relevant part of settings.py:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'example#gmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'domain <example#gmail.com>'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

It seems like google banned the usage of it's accounts for automatic email-sending. The best choice in this case is just to use another service or create an email service by yourself

Related

Django isn't able to send emails but can login into my gmail acc

My Django app is able to log in into my Gmail account, but it is not sending emails.
I know it logged in because I tried sending an email to a non-existing email-address and Gmail gave me this error.
Even looked in my spam folders but nothing :(
However, when I manually send an email, it works properly.
This is my SMTP configuration in settings.py
settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
I even tried hard-coding and changing the sender's email, but still no result.
I wasn't getting this error a few days before, but for some reason it does seem to be working now.
By the way, I'm using this for password reset functionality.

Error in sending email using gmail smtp in Django app

I set up everything as the Django documentation but when I test sending an email.It works but When I check my inbox I find out that I sent and revived from to the same email address.
Here is the 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 = "myemail#gmail.com"
EMAIL_HOST_PASSWORD = "mypassword"
And the views.py
...
send_mail( 'subject', 'message', 'user#gmail.com', ['myemail#gmail.com',], fail_silently=False, )
...
But I received an email from myemail#gmail.com to me(myemail#gmail.com).
Im not sure if you did this already but if youre using gmail then you will need to do the following.
Sign in to your Google Admin console (Sign in using an administrator account)
Click Security > Less secure apps.
Select Allow users to manage their access to less secure apps.
Click Save.25
Also you should use environment variables for the email address if you are live already eg:
EMAIL_HOST_USER = os.environ.get('MY_EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('MY_EMAIL_PASS')
If its all working and you are just getting the mail to the wrong address can you send on the document you followed?
In terms of you settings.py that looks fine to me.

Can not connect to smtp.gmail.com in Django

I'm trying to send email using smtp.gmail.com in Django project.
This is my email settings.
settings.py
# Email Settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = 'myaccount#gmail.com'
EMAIL_HOST_PASSWORD = 'mygooglepassword'
views.py
...
send_mail( "message title",
"message content",
"myaccount#gmail.com",
["myaccount#hotmail.com"],
fail_silently=False)
Whenever I try to send email, I get this error
gaierror at /contact-us/
[Errno-2] Name or service not known
I tried the followings.
I set my google account's less secure app access on.
I unchecked avast antivirus setting 'Setting->Protection->Core Shields->Mail Shield->Scan outbound emails(SMTP)'
Tried different ports in email settings. 587 and 25
Switched the ssl and tls in email settings.
But it's not sending yet. When I use 'django.core.mail.backends.console.EmailBackend' instead of 'django.core.mail.backends.smtp.EmailBackend', it prints email on console.
I double checked my gmail username and password on settings.
Please help me.
Thank you.
You may need to do some configuration on Google side.
Reference answer::
Go to your Google Account settings, find Security -> Account permissions -> Access for less secure apps, enable this option.
https://accounts.google.com/DisplayUnlockCaptcha

Sending Email with Django

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 . . .

Setting up Email Backends with Django 1.6

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

Categories