Chinaunix首页 | 论坛 | 博客
  • 博客访问: 457319
  • 博文数量: 145
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1139
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-14 16:47
个人简介

路漫漫其修远兮,吾将上下而求索

文章分类

全部博文(145)

文章存档

2016年(10)

2015年(15)

2014年(120)

我的朋友

分类: LINUX

2014-01-15 15:22:14

为避免邮件服务器管理人员每周查看黑名单,并提交黑名单申诉,如果服务器数量较多则非常麻烦。
IP列表、提交信息请自定义。
中国反垃圾邮件联盟申诉网址: 提交
此网站不需要输入验证码,故方便脚本提交申诉


python版本

点击(此处)折叠或打开

  1. #!/usr/bin/env python
  2. #encoding:utf-8
  3. import requests
  4. import re
  5. IpList=['113.212.91.25','113.212.91.23']
  6. QueryAdd=''
  7. ComplaintAdd=''
  8. data = {
  9. 'CONTENT':'''我们是一家正规的XXX。xxxxxxx。恳请将我们的发送服务器IP移出黑名单。谢谢!
  10. 处理措施:
  11. 1.XXXX。
  12. 2.XXXX。''',
  13. 'CORP':'abc.com',
  14. 'WWW':'',
  15. 'NAME':'def',
  16. 'MAIL':'def@163.com.cn',
  17. 'TEL':'010-50000000',
  18. 'LEVEL':'0',
  19. }
  20. for Ip in IpList:
  21. query = requests.post(url=QueryAdd, data={'IP':Ip}) # 黑名单查询
  22. if query.ok:
  23. if re.findall(u'\u7533\u8bc9\u8131\u79bb', query.text, re.S): # 查找关键字 申诉脱离 既表明在黑名单中
  24. data['IP']=Ip
  25. complaint = requests.post(url=ComplaintAdd, data=data) # 提交申诉
  26. if complaint.ok:
  27. if re.findall(u'\u60a8\u7684\u9ed1\u540d\u5355\u8131\u79bb\u7533\u8bf7\u5df2\u63d0\u4ea4', complaint.text, re.S):
  28. status='申请提交'
  29. elif re.findall(u'\u8131\u79bb\u7533\u8bf7\u5df2\u88ab\u4ed6\u4eba\u63d0\u4ea4', complaint.text, re.S):
  30. status='重复提交'
  31. elif re.findall(u'\u7533\u8bf7\u7531\u4e8e\u8fd1\u671f\u5185\u6709\u88ab\u62d2\u7edd\u7684\u8bb0\u5f55', complaint.text, re.S):
  32. status='近期拒绝'
  33. else:
  34. status='异常'
  35. else:
  36. status='正常'
  37. print '%s %s' %(Ip,status)
shell版本

点击(此处)折叠或打开

  1. #/bin/bash
  2. IpList=`awk '$1!~"^#"&&$1!=""{print $1}' host.list`
  3. QueryAdd=''
  4. ComplaintAdd=''
  5. CONTENT='我们是一家正规的XXX。xxxxxxx。恳请将我们的发送服务器IP移出黑名单。谢谢!
  6. 处理措施:
  7. 1.XXXX。
  8. 2.XXXX。'
  9. CORP='abc.com'
  10. WWW=''
  11. NAME='def'
  12. MAIL='def@163.com.cn'
  13. TEL='010-50000000'
  14. LEVEL='0'
  15. for Ip in $IpList
  16. do
  17. Status=`curl -d "IP=$Ip" $QueryAdd |grep 'Getout/ShowForm?IP=' |grep -wc '申诉脱离'`
  18. if [ $Status -ge 1 ];then
  19. IpStatus="黑名单中"
  20. results=`curl -d "IP=${Ip}&CONTENT=${CONTENT}&CORP=${CORP}&WWW=${WWW}&NAME=${NAME}&MAIL=${MAIL}&TEL=${TEL}&LEVEL=${LEVEL}" $ComplaintAdd |grep -E '您的黑名单脱离申请已提交|该IP的脱离申请已被他人提交|申请由于近期内有被拒绝的记录'`
  21. echo $results
  22. if echo $results | grep '您的黑名单脱离申请已提交' > /dev/null 2>&1
  23. then
  24. complaint='申诉成功'
  25. elif echo $results | grep '该IP的脱离申请已被他人提交' > /dev/null 2>&1
  26. then
  27. complaint='申诉重复'
  28. elif echo $results | grep '申请由于近期内有被拒绝的记录' > /dev/null 2>&1
  29. then
  30. complaint='申诉拒绝'
  31. else
  32. complaint='异常'
  33. fi
  34. else
  35. IpStatus='正常'
  36. complaint='无需申诉'
  37. fi
  38. echo "$Ip $IpStatus $complaint" >> $(date +%Y%m%d_%H%M%S).log
  39. done



阅读(1227) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~