QQ邮件转为html,python 发送html格式邮件到qq

#-*- coding: utf-8 -*-

__author__ = 'Alon'

__date__ = '2017/8/14 18:38'

importsys

reload(sys)

sys.setdefaultencoding('utf8')importsmtplibimporttimefrom datetime importdatetimefrom email.mime.text importMIMETextfrom email.mime.multipart importMIMEMultipart

mail_host= 'smtp.qq.com'mail_user= 'XXX@qq.com'mail_pwd= 'XXXXX'ssl_pwd= "XXXXXX"mail_to= ['XXXX5@qq.com']

subject= "【重要】在研问题单统计,收到邮件请及时处理"send_time= time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))defget_html_msg():

head= """

table.gridtable {

font-family: verdana, arial, sans-serif;

font-size: 11px;

color: #333333;

border- 1px;

border-color: #666666;

border-collapse: collapse;

60%;

table-layout: fixed;

word-break: break-all;

}

table.gridtable th {

border- 1px;

padding: 8px;

border-style: solid;

border-color: #666666;

background-color: #dedede;

}

table.gridtable td {

border- 1px;

padding: 8px;

border-style: solid;

border-color: #666666;

background-color: #ffffff;

}

"""p= """

大家好:
截止到""" + send_time + """,问题单报表如下,请责任人及时处理。

"""body= """""" + p + """
单号描述创建人创建时间当前责任人状态
50px50% aaaaaaa1111111111111111bbbbbbbccccccc50% aaaaaaabbbbbbbccccccc50px100px
50px50% aaaaaaa1111111111111111bbbbbbbccccccc50% aaaaaaabbbbbbbccccccc50px100px

"""html= """""" + head + body + """"""

returnhtmldefsend_mail(html_msg):

msg=MIMEMultipart()

content= MIMEText(html_msg, 'html')

msg.attach(content)

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

msg['From'] =mail_user

msg['Subject'] =subject

s= smtplib.SMTP_SSL(mail_host, 465)

s.login(mail_user, ssl_pwd)

s.sendmail(mail_user, mail_to, msg.as_string())

s.quit()print "ok"

if __name__ == "__main__":

now=datetime.now()

html=get_html_msg()

send_mail(html)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值