python smtplibを利用してメールを送信


import smtplib
from email.mime.text import MIMEText

mailserver = "smtp.qq.com"
from_addr = "[email protected]"
to_addrs = "[email protected]"

user = "[email protected]"
password = "xxxx"

msg = MIMEText('hello world')
msg['Subject'] = 'I miss you'
msg['From'] = 'abc'
msg['To'] = 'def'

svr = smtplib.SMTP(mailserver)
svr.set_debuglevel(1)
svr.login(user, password)
svr.sendmail(from_addr, to_addrs, msg.as_string())
svr.quit()

qqメールボックスにログインするには、smtp/popログインをサポートするメールボックスを設定する必要があります.