Pythonでメール送信

from email import message
import smtplib

smtp_host = 'smtp-mail.outlook.com'
smtp_port = 587

from_email = '送信元アドレス'
to_email = '送信先アドレス'
username = 'ユーザー名'
password = 'パスワード'

msg = message.EmailMessage()
msg.set_content('Test email')
msg['Subject'] = 'Test email sub'
msg['From'] = from_email
msg['To'] = to_email

server = smtplib.SMTP(smtp_host, smtp_port)
server.starttls()
server.ehlo()
server.login(username, password)
server.send_message(msg)
server.quit()
タイトルとURLをコピーしました