1. 程式人生 > >python接口測試之如何發送郵件

python接口測試之如何發送郵件

python3 pytho htm gin multi () from oob light

可以參考菜鳥教程:http://www.runoob.com/python3/python3-smtp.html

import smtplib
import email.mime.multipart
import email.mime.text
msg=email.mime.multipart.MIMEMultipart()
msg[‘from‘]=‘[email protected]‘
msg[‘to‘]=‘[email protected]‘
msg[‘subject‘]=‘給你的一封信‘
content="你好"
txt=email.mime.text.MIMEText(content)
msg.attach(txt)
smtp=smtplib.SMTP()
smtp.connect(‘smtp.163.com‘)
smtp.login(‘[email protected]‘,password)
smtp.sendmail(‘[email protected]‘,‘[email protected]‘,str(msg))

  

python接口測試之如何發送郵件