电子商务网站调研报告,关键词搜索爱站网,利尔化学股票,形象墙logo墙设计图为了安全起见#xff0c;我们发送邮件需要使用tls#xff0c;这样发送的内容都是加密的了#xff0c;但是该工具批量发送带有自定义内容的邮件不方便#xff0c;于是写了一个py脚本#xff0c;使用--data参数#xff0c;方便批量发送#xff0c;我们的策略是每天随机发送…为了安全起见我们发送邮件需要使用tls这样发送的内容都是加密的了但是该工具批量发送带有自定义内容的邮件不方便于是写了一个py脚本使用--data参数方便批量发送我们的策略是每天随机发送150至200个人具体看公司规模而定。每个邮箱客户端使用的邮件头还不一样我们测试了用qq邮箱头发给outlook没有问题由于我们公司默认都是outlookfoxmail没有测应该问题也不大有问题增删相关邮件头字段即可。下面是批量发送脚本内容(命名为mail.py):
import time
import sys
import subprocess
#发送的完整邮件内容有2部分组成一部分是收件人是可变的一部分是邮件内容是不变的内容使用file_c变量收件人使用file_f变量具体看脚本内容file_c Subject: ?gb2312?B?xxxxxxxdLss6M?
#主题等都是gb2312编码后的base64加密
#Thread-Topic: ?gb2312?B?0/Lxxxxxxxxxss6M?
Thread-Index: AdT6eO/KxxxxxxxxxxxxxxxxIKA
Date: {time.ctime()} 0800
#发送邮件是提前发送的模板邮件所以需要获取当前时间作为发送时间不然接收的时间会不对
Accept-Language: zh-CN, en-US
Content-Language: zh-CN
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [x.x.x.x]
Content-Type:xxxxxxxxx;
Return-Path: administratorxxx.com
xxx内容xxx file open(f/usr/local/src/{sys.argv[1]}, r)
names file.readlines()
for name in names:file_f fTo: {name.strip()} {name.strip()}\n#print(file_f)with open(/usr/local/src/file.txt, w) as f:f.writelines(file_f file_c)status subprocess.Popen([swaks, --tls, --data, /usr/local/src/file.txt, --to, name.strip(), --from, administratorxxx.com], stdoutsubprocess.PIPE)lg status.stdout.readlines()print(type(lg))with open(/usr/local/src/log.txt, a) as g:for line in lg:g.write(line.decode())发送对象名单保存在sec.txt中运行 python mail.py sec.txt 即可。