首页 > 代码库 > python-发送邮件
python-发送邮件
来自:http://www.cnblogs.com/lonelycatcher/archive/2012/02/09/2343463.html#commentform
- #!/usr/bin/env python3
- #coding: utf-8
- import smtplib
- from email.mime.text import MIMEText
- from email.header import Header
- sender = ‘***‘
- receiver = ‘***‘
- subject = ‘python email test‘
- smtpserver = ‘smtp.163.com‘
- username = ‘***‘
- password = ‘***‘
- msg = MIMEText(‘你好‘,‘text‘,‘utf-8‘)#中文需参数‘utf-8’,单字节字符不需要
- msg[‘Subject‘] = Header(subject, ‘utf-8‘)
- smtp = smtplib.SMTP()
- smtp.connect(‘smtp.163.com‘)
- smtp.login(username, password)
- smtp.sendmail(sender, receiver, msg.as_string())
- smtp.quit()
目前只是过这种。
python-发送邮件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。