Home > Software design >  Why am I getting an authentication error?
Why am I getting an authentication error?

Time:04-13

I enabled "less secure apps" but still getting this error. Password and login are correct

import subprocess, smtplib

def send_mail(email, password, message):
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    server.login(email, password)
    server.sendmail(email, email, message)
    server.quit()

comand = "netsh wlan show profile"
result = subprocess.check_output(comand, shell=True)
send_mail("my email", "my password", result)
Traceback (most recent call last):
  File "d:/asdasd/main.py", line 12, in <module>
    send_mail("my email", "my password", result)
  File "d:/asdasd/main.py", line 6, in send_mail
    server.login(email, password)
  File "C:\Python27\lib\smtplib.py", line 623, in login
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, '5.7.8 Username and Password not accepted. Learn more at\n5.7.8  https://support.google.com/mail/?p=BadCredentials b3-20020a056512304300b004488e49f2fasm2187075lfb.129 - gsmtp')

CodePudding user response:

You need to create a app passwort on google account.

just google "gmail application specific password"

BR

  • Related