#!/usr/bin/env python #_*_ coding: utf-8 _*_ import smtplib from email.mime.text import MIMEText from email.header import Header sender = 'xxxxxxx@xxxxxx.com' #发件人 receiver = ['xxxxxxx@qq.com'] #收件人 subject = 'python email test' #定义主题 smtpserver = 'mail.urundp.com' #第三方smtp服务器 username = 'xxxxx@xxxxxx.com' #用户名 password = 'xxxxxxxx' #密码 msg = MIMEText('Python mail test','plain','utf-8') #格式:邮件内容/格式/编码 msg['Subject'] = Header(subject, 'utf-8') try: smtp = smtplib.SMTP() smtp.connect('mail.urundp.com') smtp.ehlo() smtp.starttls() smtp.login(username, password) smtp.sendmail(sender, receiver, msg.as_string()) smtp.quit() print '邮件发送成功' except smtplib.SMTPException,ex: print '邮件发送失败',ex
python smtplib模块(实现调用第三方smtp服务器发送邮件)
原创
©著作权归作者所有:来自51CTO博客作者TtrToby的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
记录利用泛型实现第三方接口数据快速对接
泛型,第三方接口数据同步
数据 List json -
第三方q