サンプルスクリプトPythonからメール送付
以下が、サンプルスクリプトになります。
import smtplib from email.mime.text import MIMEText from email.header import Header from email.utils import formatdate def send_email(to_adress, send_subject, send_message): from_address = 'xxx@xxx.com' charset = 'iso-2022-jp' msg = MIMEText(send_message, 'plain', charset) msg['Subject'] = Header(send_subject, charset) msg['From'] = from_address msg['To'] = to_adress msg['Date'] = formatdate(localtime=True) smtp = smtplib.SMTP('@@smtp_adress@@') smtp.sendmail(from_address, to_address, msg.as_string()) smtp.quit() send_email('aaa@bbbb.com', 'サブジェクト', 'メッセージ本文')