python smtplib 发送邮件
来源:互联网 发布:c语言if else嵌套 编辑:程序博客网 时间:2024/05/28 06:08
#coding=utf-8import smtplibfrom email.mime.text import MIMETextfrom email.header import Header#发送邮箱sender = 'xxxx@163.com'#接收邮箱receiver = 'xxxxx@qq.com'#发送邮件主题subject = 'python email test'#发送邮箱服务器smtpserver = 'smtp.163.com'#发送邮箱用户/密码username = 'xxxxx@163.com'password = 'xxxxxx'msg = MIMEText('<html><h1>你好!</h1></html>','html','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()
运行的时候 报错 smtplib.SMTPDataError: (554, 'DT:SPM 163 smtp14
最后加上了这两行代码就行了
#coding=utf-8import smtplibfrom email.mime.text import MIMETextfrom email.header import Header#发送邮箱sender = 'xxxxx@163.com'#接收邮箱receiver = 'xxxxxx@qq.com'#发送邮件主题subject = 'python email test'#发送邮箱服务器smtpserver = 'smtp.163.com'#发送邮箱用户/密码username = 'xxxxx@163.com'password = 'xxxxxx'msg = MIMEText('<html><h1>你好!</h1></html>','html','utf-8')msg['Subject'] = Header(subject, 'utf-8')msg['From'] = 'xxxxx@163.com'msg['To'] = 'xxxxxx@qq.comsmtp = smtplib.SMTP()smtp.connect('smtp.163.com')smtp.login(username, password)smtp.sendmail(sender, receiver, msg.as_string())smtp.quit()
阅读全文
0 0
- #python# smtplib 邮件发送
- Python 邮件发送smtplib
- python smtplib 发送邮件
- python 利用smtplib发送邮件
- Python使用smtplib发送邮件
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- 转:python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- python模块学习 ---- smtplib 邮件发送
- python发送邮件sendmail--smtplib【带附件】
- 使用python内置smtplib模块发送邮件
- python:利用smtplib模块发送邮件
- python smtplib包发送163邮件
- linux-C下的死锁检测(pthread_mutex_)
- TyrantMaster(2)
- get和post的区别
- 二维码
- kafka中的topic为什么要进行分区?
- python smtplib 发送邮件
- [算法分析与设计] leetcode 每周一题: 030. Substring with Concatenation of All Words
- HDU 2047 阿牛的EOF牛肉串
- 前缀和
- Python安装教程
- Titan数据库快速入门之神的光芒
- HashMap为什么是不安全的?HashTable和ConcurrentHashMap为什么是安全的 ?
- IDEA导出jar包后运行报错 找不到或无法加载主类
- 如何提高SSH的安全性?