https://support.google.com/accounts/answer/185833?hl=ja Juste à partir d'ici. Vous pouvez obtenir un mot de passe d'application à 16 chiffres.
# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
if __name__ == '__main__':
to_addr = '[email protected]'
from_addr = '[email protected]'
mail_id = from_addr
#Entrez le mot de passe à 16 chiffres obtenu
mail_pass = 'wwwwxxxxyyyyzzzz'
message = MIMEText('Hello')
message['Subject'] = 'Hello'
message['From'] = from_addr
message['To'] = to_addr
sender = smtplib.SMTP_SSL('smtp.gmail.com')
sender.login(mail_id, mail_pass)
sender.sendmail(from_addr, to_addr, message.as_string())
sender.quit()
Recommended Posts