As of may 30th, smtp is no longer accepted.
https://support.google.com/accounts/answer/6010255?hl=en&ref_topic=7188673
What is the new way to make a simple python emailer rather than a full application with the "login with google" option?
Not sure why I was asked for the code and error, given that I already diagnosed the issue and was asking for alternative methods. Here it is. Its a handy emailer that texts me to workout when I work at home.
import time
import smtplib
import random
gmail_user = '[email protected]'
gmail_password = 'TheCorrectPassword'
sent_from = gmail_user
to = ['[email protected]']
exercises = ['push ups', 'jumps in place', '20lb curls', 'tricep extensions', 'quarter mile runs']
levels = [1, 2, 3]
level1 = ['10', '15', '16', '20', '1']
level2 = ['15', '30', '30', '40', '2']
level3 = ['20', '50', '48', '70', '4']
while True:
if int(time.strftime('%H')) > 9:
if int(time.strftime('%H')) < 23:
abc = random.uniform(0, 1)
picker = random.randint(0, 4)
if abc < 0.3:
level = level1
if 0.3 < abc and abc < 0.8:
level = level2
if abc > 0.8:
level = level3
exersize = exercises[picker]
amount = level[picker]
try:
subject = f'Test'
body = f'Do {amount} {exersize}'
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.ehlo()
server.login(gmail_user, gmail_password)
server.sendmail(sent_from, to, body)
server.close()
print('Email sent!')
except Exception as error:
print(error)
time.sleep(random.randint(1500, 4800))
time.sleep(100)
error:
(535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials jj1-20020a170903048100b00163247b64bfsm7655137plb.115 - gsmtp')
Solved below: SMTP is still accepted for app passwords. App passwords creation steps can be found here, but you must enable 2 factor auth first, before app passwords can be created.
https://support.google.com/accounts/answer/185833 https://myaccount.google.com/security