python smtp 邮件发送,pythonsmtp,[Python]代码#c


[Python]代码

#coding:utf-8'''author:fc_lampblog:fc-lamp.blog.163.com'''import smtplibimport base64def smtp(fromadd='[email protected]',toadd='',subject='',body=''):    #初始化    smtp = smtplib.SMTP()    #链接服务器    smtp.connect('[email protected]',25)    #等录认证    smtp.login('[email protected]','xxxxxxx')    #格式信息    body = base64.b64encode(body)    msg = 'From:%s\nTo:%s\nSubject:%s\nContent-Type:text/html\nContent-Transfer-Encoding:base64\n\n%s'%(            fromadd,toadd,subject,body        )    #发送信息    smtp.sendmail(fromadd,toadd,msg)    #退出    smtp.quit()#测试一下smtp(fromadd='[email protected]',toadd='[email protected]',subject='这里是测试风格二哦',body='哈哈哈223232看了!!')

评论关闭