excel学习库

excel表格_excel函数公式大全_execl从入门到精通

python 读取数据库中的文件 保存excel 并发送邮箱

def send_mail(send_mail):

# 发送邮箱服务器

smtp_server = 'smtp.163.com'

# 发送邮箱用户名密码

user = '15230831989@163.com'

password = 'OLSXOLCKOPJJWKFI'

# 接收邮箱

receives = ['1324176145@qq.com','3593882608@qq.com']

# 发送邮件和主题内容

subject = '爬取58司机发送邮件 【流程测试】'

content = '<html><h1 style="color:red">测试邮件发送</h1></html>'

# 构建发送与接收信息

msg_root = MIMEMultipart()

msg_root.attach(MIMEText(content, 'html', 'utf-8'))

msg_root['subject'] = subject

msg_root['From'] = user

msg_root['To'] = ','.join(receives)

# msg_root['To'] = '3593882608@qq.com'

# 构造附件3(附件为HTML格式的网页)

att3 = MIMEText(open(send_mail, 'rb').read(), 'base64', 'utf-8')

att3["Content-Type"] = 'application/octet-stream'

att3["Content-Disposition"] = 'attachment; filename='+send_mail.split('/')[-1]+''

msg_root.attach(att3)

# SSL协议端口号要使用465

smtp = smtplib.SMTP_SSL(smtp_server, 465)

# H E L O 向服务器标识用户身份

smtp.helo(smtp_server)

# 服务器返回结果确认

smtp.ehlo(smtp_server)

# 登录邮箱服务器用户名和密码

smtp.login(user, password)

print("Start send email...")

smtp.sendmail(user, receives, msg_root.as_string())

smtp.quit()

print("Send End!")

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

«    2024年12月    »
1
2345678
9101112131415
16171819202122
23242526272829
3031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
    文章归档
      友情链接