python發送html格式的table數據(帶認證,587端口)

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="""
<html>
<head></head>
<body>
<table border="1">
<tr>
<th>1</th>
<th>2</th>
</tr>
<td>aa</td>
<td>bb</td>
</tr>
</table>
</body>
</html>
"""

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章