Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >python发送、抄送邮件

python发送、抄送邮件

作者头像
py3study
发布于 2020-01-08 08:15:24
发布于 2020-01-08 08:15:24
1K00
代码可运行
举报
文章被收录于专栏:python3python3
运行总次数:0
代码可运行

python发送抄送邮件

sendemial.py

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.mime.multipart import MIMEMultipart
import time
import  os


mail_host="smtp.miao.cn"
mail_user="wei@miao.cn"
mail_pass="qwe"
sslPort="465"
time1=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))


sender = 'wei@miao.cn'
to_reciver = ['wei@miao.cn']
cc_reciver =[ 'dongya@126.com']
reciver = to_reciver + cc_reciver

message = MIMEText('dddddddddd', _subtype='html', _charset='utf-8')

message['From'] =  sender
message['To'] = ";".join(to_reciver)
message['Cc'] = ";".join(cc_reciver)

subject ='接口自动化测试报告'+'-'+time1
message['Subject'] = Header(subject, 'utf-8')


try:


    smtpObj = smtplib.SMTP_SSL(mail_host,sslPort)
    smtpObj.ehlo()
    smtpObj.login(mail_user,mail_pass)
    smtpObj.sendmail(sender,reciver, message.as_string())


    print ("邮件发送成功")

except Exception as n:
        print ("Error: 无法发送邮件")
        print(n)
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/09/08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验