If you want a automate your email via Google SMTP with your Python code, try this out.
This is a very basic code to understand the protocol that handles sending emails and routing emails between mail servers using SMTP (Simple Mail Transfer Protocol).
But don't use it to send spam to anyone :) just use for study case
Here, more Google help doc link,
https://support.google.com/a/answer/176600?hl=en#zippy=%2Cuse-the-gmail-smtp-server
import smtplib
try:
SMTP_Server = 'smtp.gmail.com'
SMTP_Server_Session = 587
id = '<Email ID>'
password = '<Password>'
reciever = '<Email address>'
smtpObj = smtplib.SMTP(SMTP_Server, SMTP_Server_Session) # creates SMTP session
smtpObj.starttls() # start TLS for security, Google : 587
smtpObj.login(id, password)
subject = 'SMTP e-mail test'
body = 'This message is sent from Python SMTP test code.\nHave a great day!\n\nfrom Mink '
message = 'Subject: {}\n\n{}'.format(subject, body)
smtpObj.sendmail(id, reciever, message)
smtpObj.quit()
except Exception as e:
print(e)
and you can get an e-mail like this...