python==使用smtp发送邮件的源代码,解决554错误码的问题,,import smt
python==使用smtp发送邮件的源代码,解决554错误码的问题,,import smt
import smtplibfrom email.mime.text import MIMETextfrom email.header import Headerimport timedef email(): #发送邮箱服务器 smtpserver = "smtp.163.com" #发送邮箱的账号/密码 user= "我的邮箱@163.com" password="我的密码" #发送邮箱 sender="我的邮箱@163.com" #收件箱 receiver = "你的邮箱@qq.com" #发送主题 subject = "《脑筋急转弯》" #编写HTML类型的邮件正文 msg = MIMEText("<html><h1>ssssssssssssssss</h1></html>","html","utf-8") msg[‘Subject‘] = Header(subject, ‘utf-8‘) try: #这两个参数必须要,不然就会出现554的错误,不然少参数 msg[‘from‘]=sender msg[‘to‘]=receiver #连接发送邮箱 smtp = smtplib.SMTP() smtp.connect(smtpserver) smtp.login(user,password) smtp.sendmail(sender, receiver, msg.as_string()) smtp.quit() print("执行第",i,"次,成功!") time.sleep(2) except: print("第",i,"次发送失败!")i=1while i: email() i +=1 if i >3: break
python==使用smtp发送邮件的源代码,解决554错误码的问题
相关内容
- 粗解python的@classmethod和@staticmethod及普通实例方法,,引
- 写了一个预约东南大学体育场馆的python脚本,目前刚刚
- python数据库的增删改查,,#coding=ut
- Python常用模块之hashlib,pythonhashlib,Python里面的h
- python global 和 nonlocal 的理解,,参考:https:/
- 【Python】[08]基于CGI的Web开发,python08cgiweb,开始web开发前
- python-面向对象(绑定方法与非绑定方法),python-面向
- Python - 多元组(tuple),pythontuple,声明一个多元组(4,
- python 基础课程,,先来个练习统计统计一
- python异常中的else作用,,一、概念异常:常见的
评论关闭