Skip to content

Instantly share code, notes, and snippets.

@jackyshan
Created December 6, 2016 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jackyshan/df1310d79d870f50b0e732f7b0b02e15 to your computer and use it in GitHub Desktop.
Save jackyshan/df1310d79d870f50b0e732f7b0b02e15 to your computer and use it in GitHub Desktop.
python批量发送邮件
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import urllib2, time, string, random
email = ''
title = raw_input("输入邮件标题:")
if len(title) <= 0:
title = '标题'
pass
content = raw_input("输入邮件内容:")
if len(content) <= 0:
content = '内容'
pass
f = open("mail.txt") # 返回一个文件对象
email = f.readline() # 调用文件的 readline()方法
email = email.strip()
while email:
rdstr = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10))
url = 'http://192.168.0.52/sendmail/'+email+'/'+title+'/'+content+' '+rdstr
print url
resp = ''
try:
resp = urllib2.urlopen(url)
except Exception as e:
email = f.readline()
email = email.strip()
continue
raise
else:
pass
finally:
pass
print email+ ' send ' +resp.read()
time.sleep(50)
email = f.readline()
email = email.strip()
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment