python发送html格式的table数据(带认证,587端口)

vi mailtable.py

#!/usr/bin/python

-- coding:UTF-8 --

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header

smtpserver='smtp.ming.com'

username='[email protected]'

password='xxxxxx'

sender='[email protected]'

receiver = ['[email protected]','[email protected]']

subject='aa'

msg=MIMEMultipart('mixed')

msg['Subject']=subject

msg['From']='[email protected]'

msg['To']=";".join(receiver)

html="""











12
aabb



"""

text_html=MIMEText(html,'html','utf-8')
msg.attach(text_html)

smtp=smtplib.SMTP()
smtp.connect('smtp.ming.com',587)
smtp.starttls()
smtp.login(username,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()

:wq

执行

python mailtable.py