博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python标准库之【smtplib】
阅读量:6998 次
发布时间:2019-06-27

本文共 588 字,大约阅读时间需要 1 分钟。

import smtplib

SMTPserver = 'smtp.163.com'

fromaddr = 'a@163.com'

toaddr = 'b@qq.com'

MsgHead = ['From:a@163.com','To:b@qq.com','Subject':'Lalalal']

MsgBody = ['balalla','aaaaa']

Msg = '\r\n\r\n'.join(['\r\n'.join(MsgHead),'\r\n'.join(MsgBody)])

s = smtplib.SMTP()

s.connect(SMTPserver)

s.login('a','***')

s.sendmail(fromaddr,toaddr,Msg)

 

 

 

from email.mime.text import MIMEText

text  = urllib.urlopen('http://www.baidu.com').read()

msg = MIMEText(text,'html','utf8')

msg.set_charset('utf8')

 

s.sendmail(fromaddr,toaddr,msg.as_string())

转载于:https://www.cnblogs.com/programmersong/p/3496782.html

你可能感兴趣的文章