現在以下のようなメール送信のプログラムを作成し、これの送り先のメールアドレスを変数にして複数のメールアドレスに切り替えられるようにしようと考えているのですが、始めたばかりなのでやり方がよくわかりません。どうかアドバイス、解決策をお願いいたします。
python
1コード 2#!/usr/bin/python 3# -*- coding: utf-8 -*- 4# Import smtplib for the actual sending function 5import smtplib 6# Import the email modules we'll need 7from email.mime.multipart import MIMEMultipart 8from email.mime.text import MIMEText 9me = 'yyy@gmail.com'#発信 10you = 'xxx@gmail.com'#送り先 11msg = MIMEMultipart('alternative') 12# 件名、宛先 13msg['Subject'] = '郵便です' 14msg['from'] = me 15msg['To'] = you 16# 本文 17def send(): 18 19 body_text = '寮のポストに郵便が届きました' 20 msg.attach(MIMEText(body_text, 'plain', 'utf-8')) 21# Send the message via our own SMTP server, but don't include the envelope head$ 22 s = smtplib.SMTP_SSL('smtp.gmail.com', 465) 23 s.login('xxx@gmail.com','パスワード') 24 s.sendmail( me, [you], msg.as_string() ) 25 s.close() 26 27send() 28
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/15 02:33
2017/11/15 02:42