https://support.google.com/accounts/answer/185833?hl=ja Just set from here. You can get a 16-digit app password.
# -*- 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
#Enter the obtained 16-digit password
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