CoreyMSchafer/code_snippets

(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials gj6sm7456452pjb.10 - gsmtp')

msMohit20 opened this issue · 43 comments

i am middle of the project and i was connecting django with gmail and i got this type of error.....

settings.py code for :

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

what should is in this !!!?

AND AS I AM PUTTING ANOTHER GMAIL ID IT SHOW THAT MAIL IS SENT BUT I CAN'T SEE THAT MAIL ANYWHERE???????????????????

Enable less secure app login for your google account, by default google doesn't allow you to login to smtp server.
Go here >>https://myaccount.google.com/lesssecureapps
and enable it and you will be good to go.

Thanks man

Show This Error:
(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials m1sm1619710pjo.10 - gsmtp')

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = '(Here I Give My Email)'
EMAIL_HOST_PASSWORD = '(Here I Give My Email Password)'

every thing is complete but email not send....!!!

@edward795
I alredy enable less secure app.
suggest me plz...

@edward795
I have the same problem even after enabling a less secure app. The issue has been solved. Now it is working. Thanks Man.

tyhho commented

@dipakbera
Hello, would you mind sharing what solved your issue in the end? In our case we also enabled less secure app but the same error shows up. Thanks!

tyhho commented

Thanks for getting back to me @dipakbera .
We solved the problem eventually by using a Google generated App Password. It looks like using the login pw was the problem for us before.
https://support.google.com/accounts/answer/185833?hl=en
2FA is still needed to generate this App pw but miraculously it solved the problem.
Thank you again!

Hello guys,

Here's how we are able to solve this problem:

Django SMPT Error answer:

https://support.google.com/mail/answer/7126229?p=BadCredentials&visit_id=637758197720369506-3330444657&rd=2#cantsignin&zippy=%2Ci-cant-sign-in-to-my-email-client

Steps:

1. Create 2-Step Authentication

https://support.google.com/accounts/answer/185839

2. Create App Password

https://support.google.com/accounts/answer/185833

3. Use the APP password as your EMAIL_HOST_PASSWORD in your settings file

It should work after that 👍

how to show this using the alert box in GUI tkinter?

how to show this using the alert box in GUI tkinter?
Hello!! What want you to show using alert box

Hello guys,

Here's how we are able to solve this problem:

Django SMPT Error answer:

https://support.google.com/mail/answer/7126229?p=BadCredentials&visit_id=637758197720369506-3330444657&rd=2#cantsignin&zippy=%2Ci-cant-sign-in-to-my-email-client

Steps:

1. Create 2-Step Authentication

https://support.google.com/accounts/answer/185839

2. Create App Password

https://support.google.com/accounts/answer/185833

3. Use the APP password as your EMAIL_HOST_PASSWORD in your settings file

It should work after that +1

Not working for me dear

enable access to the less secure app is ON, still seeing the same error? does anyone got solution.

From google.

To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.

https://support.google.com/accounts/answer/6010255?hl=en

I tried to find that section of enabling less secure apps on google account, but it was available, This is the message I am getting from less secure app of my newly created account

This setting is no longer available

From Google, the say they longer supports the use of third-party apps or devices which ask you to sign in to
your Google Account using only your username and password

Hi, it seems google have disabled the toggle.
I am unable to turn on less secure apps from my end

has anyone managed to come up with solution regarding this isssue.

has anyone managed to come up with solution regarding this isssue.
waiting for the solution...

has anyone managed to come up with solution regarding this isssue.
waiting for the solution...

I have manged to fix my issue as Google have disabled the less secure apps recently. All I had to do was make my google account 2 factor authentication, then generate a new app password to use within the settings.py of django app for email password. Hope it helps

has anyone managed to come up with solution regarding this isssue.
waiting for the solution...

I have manged to fix my issue as Google have disabled the less secure apps recently. All I had to do was make my google account 2 factor authentication, then generate a new app password to use within the settings.py of django app for email password. Hope it helps

How did you generate a new password?

I am trying to solve this problem, I have now the authentication in 2 factors, but I got block. And I need to solve faster this problem for a project that I need to present in few days

Go to your google account settings. Go to Security. then Turn on 2-step verification. Then App Password ta will be enable. From App Password you can generate password. use this password for authentication purposes

Show This Error: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials m1sm1619710pjo.10 - gsmtp')

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_USE_TLS = True EMAIL_PORT = 587 EMAIL_HOST_USER = '(Here I Give My Email)' EMAIL_HOST_PASSWORD = '(Here I Give My Email Password)'

every thing is complete but email not send....!!!

Now you cannot turn on less secure app as the deadline was 30th May 2022

I am using flask and same issue is happening for me .
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials i14-20020a170902c94e00b0016c4331e61csm579079pla.137 - gsmtp')

what to do?

Hey, community, I did as follows and read everyone's comments in this thread and I keep getting the same kickback message.

Hey, I have fixed it. You need to go into your google accounts settings and then go to "security". Then scroll down to "app passwords". There you can generate a code that will work as a password.

Do not share that code with anyone.

I was able to complete this. Hope this helps.

Feel free to ask more.

Hey, I have fixed it. You need to go into your google accounts settings and then go to "security". Then scroll down to "app passwords". There you can generate a code that will work as a password.
Do not share that code with anyone.
I was able to complete this. Hope this helps.
Feel free to ask more.

I did go into my Google Mail Settings and Turned on the 2 Step Verification and created the App Password. I put that password into my Settings.py and I still get:

SMTPAuthenticationError at /register/
(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials b22-20020a63e716000000b004298d7b6e70sm1862321pgi.54 - gsmtp')

The Code Reads as follows:

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 = 'from.********@gmail.com'
EMAIL_HOST_PASSWORD = '****************'

The code in

Signals.py

from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver

from django.contrib.auth.models import User
from .models import Profile

from django.core.mail import send_mail
from django.conf import settings

@receiver(post_save, sender=Profile)

def createProfile(sender, instance, created, **kwargs):
if created:
user = instance
profile = Profile.objects.create(
user=user,
username=user.username,
email=user.email,
name=user.first_name,
)

    subject = 'Welcome to DevSearch'
    message = 'We are glad you are here!'

    send_mail(
        subject,
        message, 
        settings.EMAIL_HOST_USER,
        [profile.email],
        fail_silently=False,
    )

Enable less secure app login for your google account, by default google doesn't allow you to login to smtp server. Go here >>https://myaccount.google.com/lesssecureapps and enable it and you will be good to go.

it doesnt work anymore