In this video we show how to use a python function to send an email with Gmail using the smtplib. We also show one of the most common problems which is caused by the Less secure app access setting in your google account.
Function Code:
import smtplib
def sendEmail(To, Subject, Message):
gmail_user = 'your.email@gmail.com'
gmail_password = 'yourPassword'
msg = "\r\n".join([
"From: " + gmail_user,
"To: " + To,
"Subject: " + Subject,
"",
Message + " "
])
try:
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(gmail_user, gmail_password)
server.sendmail(gmail_user, To, msg)
server.close()
print ('Email sent!')
except:
print ('Something went wrong...')
Sur cette page du site, vous pouvez voir la vidéo en ligne Python Email Function with Gmail durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur I.O. Pierce 30 octobre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 115 fois et il a aimé 2 téléspectateurs. Bon visionnage!