python 邮件自动发送客户端
来源:互联网 发布:门面广告牌制作软件 编辑:程序博客网 时间:2024/05/22 08:24
#!/usr/local/bin/python3
#-*- encoding: utf-8 -*-
import smtplib
from email.header import Header
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import sys
import os
smtp_server='smtp.gmail.com'
smtp_user='***'
smtp_pwd='***'
def mailMsgSend(from_addr, to_addr, subject, confile, attfile):
msg = MIMEMultipart()
msg.attach(MIMEText(open(confile,'r').read(),'plain','gb2312'))
basename = os.path.basename(attfile)
att = MIMEText(open(attfile,'rb').read(), 'base64', 'gb2312')
att['Content-Type'] = 'application/octet-stream'
#att['Content-Type'] = 'text/plain'
att['Content-Disposition'] = 'attachment; filename=%s' % basename.encode('utf-8')
msg.attach(att)
msg['to'] = ';'.join(to_addr)
msg['from'] = from_addr
msg['subject']= Header(subject, 'utf-8')
try:
s = smtplib.SMTP_SSL(smtp_server)
s.login(smtp_user, smtp_pwd)
send_msg = msg.as_string()
s.sendmail(msg['from'], msg['to'], send_msg)
s.close()
return True
except Exception as e:
print(str(e))
return False
if __name__ == '__main__':
from_address = '***@gmail.com'
mailto_list=["***@asiainfo-linkage.com"
,"***@asiainfo-linkage.com"
confile = sys.argv[1]
attfile = sys.argv[2]
try:
if mailMsgSend(from_address, mailto_list,'程序代码更改邮件', confile, attfile):
print('成功发送邮件')
else:
print('发送邮件失败')
except Exception as e:
print(str(e))
- python 邮件自动发送客户端
- python自动发送邮件
- python ------ 自动发送邮件
- python邮件自动发送
- Python自动发送邮件
- C# 简易邮件客户端,自动发送邮件
- Python(8) 自动发送邮件
- 使用python自动发送邮件
- 利用Python自动发送邮件
- Python--脚本自动发送邮件
- Python 发送带附件邮件客户端
- Web邮件发送客户端 [ html + php + python ]
- python邮件随机自动发送器
- 【Python学习笔记】-自动发送邮件脚本
- python自动发送报警监控邮件
- Python使用SMTP自动发送邮件
- 自动邮件发送程序Python版本
- Python自动发送邮件的脚本源码
- DELPHI中操作ACCESS数据库
- 股票研读
- 伤不起啊,信息
- 在Delphi中静态调用DLL 引用外部Dll External Dll 导入Dll
- 好久没来这儿关顾了
- python 邮件自动发送客户端
- chrome标签修正特性漏洞
- Delphi Format函数用法
- Excel VBA - Sheet对象
- Java自定义的类加载器
- delphi6 函数大全使用详解
- 一元多项式的相加减
- 小弟开博客啦
- Delphi 中串口通讯的实现