标签:exce style 邮箱 smtplib weight subject except 使用 失败
# coding=utf-8
import smtplib
from email.mime.text import MIMEText
import email
def sen(file_new):
msg_from = ‘87419XX@qq.com‘ # 发送方邮箱
passwd = ‘xthwzlXXX‘ # 填入发送方邮箱的授权码
msg_to = ‘1804659XXX@163.com‘ # 收件人邮箱
subject = "python邮件测试" # 主题
content = "这是我使用python smtplib及email模块发送的邮件" # 正文
msg = MIMEText(content)
msg[‘Subject‘] = subject
msg[‘From‘] = msg_from
msg[‘To‘] = msg_to
try:
s = smtplib.SMTP_SSL("smtp.qq.com", 465) # 邮件服务器及端口号
s.login(msg_from, passwd)
s.sendmail(msg_from, msg_to, msg.as_string())
print("发送成功")
except :
print("发送失败")
finally:
s.quit()
标签:exce style 邮箱 smtplib weight subject except 使用 失败
原文地址:https://www.cnblogs.com/unan/p/9962626.html