一个spamc协议库。帮助您使用spamassassin的spamd服务。

spamclib的Python项目详细描述


spamclib


一个spamc协议库。帮助您使用spamassassin的spamd服务。

功能支持

  • Support sync client.
  • Support async client.
  • Support TLS.

安装

pip安装spamclib

示例


同步客户端

#!/usr/bin/python3# -*- coding: utf-8 -*-fromspamclib.spamc_sync_clientimportSyncSpamcClientGTUBE='''Subject: Test spam mail (GTUBE)Message-ID: <GTUBE1.1010101@example.net>Date: Wed, 23 Jul 2003 23:30:00 +0200From: Sender <sender@example.net>To: Recipient <recipient@example.net>Precedence: junkMIME-Version: 1.0Content-Type: text/plain; charset=us-asciiContent-Transfer-Encoding: 7bitThis is the GTUBE, the	Generic	Test for	Unsolicited	Bulk	EmailIf your spam filter supports it, the GTUBE provides a test by which youcan verify that the filter is installed correctly and is detecting incomingspam. You can send yourself a test mail containing the following string ofcharacters (in upper case and with no white spaces and line breaks):XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34XYou should send this test mail from an account outside of your network.'''if__name__=='__main__':sc=SyncSpamcClient()# ping cannot support SpamAssassinForWindowssc.command_ping()sc.command_skip()res=sc.command_check(GTUBE.encode('utf-8'))print(res)print('Status code : %d'%res.status_code)print('Status message : %s'%res.status_message.decode('utf-8'))print('Header item Spam : %s'%res.get_header(b'Spam').decode('utf-8'))print('Response body : %s'%res.body.decode('utf-8'))sc.command_headers(GTUBE.encode('utf-8'))sc.command_process(GTUBE.encode('utf-8'))sc.command_report(GTUBE.encode('utf-8'))sc.command_report_ifspam(GTUBE.encode('utf-8'))sc.command_symbols(GTUBE.encode('utf-8'))pass

异步客户端

#!/usr/bin/python3# -*- coding: utf-8 -*-importasynciofromspamclib.spamc_async_clientimportAsyncSpamcClientGTUBE='''Subject: Test spam mail (GTUBE)Message-ID: <GTUBE1.1010101@example.net>Date: Wed, 23 Jul 2003 23:30:00 +0200From: Sender <sender@example.net>To: Recipient <recipient@example.net>Precedence: junkMIME-Version: 1.0Content-Type: text/plain; charset=us-asciiContent-Transfer-Encoding: 7bitThis is the GTUBE, the	Generic	Test for	Unsolicited	Bulk	EmailIf your spam filter supports it, the GTUBE provides a test by which youcan verify that the filter is installed correctly and is detecting incomingspam. You can send yourself a test mail containing the following string ofcharacters (in upper case and with no white spaces and line breaks):XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34XYou should send this test mail from an account outside of your network.'''bytes_GTUBE=GTUBE.encode('utf-8')if__name__=='__main__':loop=asyncio.get_event_loop()sc=AsyncSpamcClient(loop=loop)# ping cannot support SpamAssassinForWindowsloop.run_until_complete(sc.command_ping())loop.run_until_complete(sc.command_skip())res=loop.run_until_complete(sc.command_check(bytes_GTUBE))print(res)print('Status code : %d'%res.status_code)print('Status message : %s'%res.status_message.decode('utf-8'))print('Header item Spam : %s'%res.get_header(b'Spam').decode('utf-8'))print('Response body : %s'%res.body.decode('utf-8'))loop.run_until_complete(sc.command_headers(bytes_GTUBE))loop.run_until_complete(sc.command_process(bytes_GTUBE))loop.run_until_complete(sc.command_report(bytes_GTUBE))loop.run_until_complete(sc.command_report_ifspam(bytes_GTUBE))loop.run_until_complete(sc.command_symbols(bytes_GTUBE))pass

许可证

麻省理工学院许可证

谢谢

项目引用的一部分aiospamc 谢谢MJCALEY

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
尝试连接到Red5服务器时出现java问题   java实现Runnable的类被认为是ExecutorServices的“Runnable任务”?   java struts2类中的多个@validation   java未能应用插件[class'org.gradle.api.plugins.scala.ScalaBasePlugin']:gradle v2。13   如何使用Java流仅收集长度最大的元素?   从spring引导应用程序连接到firestore的java引发空指针异常   java从SQLite插入和获取真实数据类型会为连续插入获取空值吗?   当存在未知数量的空格时,使用java替代正向查找   部署如何为当今的浏览器部署java小程序(小程序、嵌入、对象)?   @OneToMany和@ManyToOne@Formula之间的java双向关系返回null   java为什么在我的例子中,协议缓冲区的性能比JSON差?   如何部署混合C++/Java(JNI)应用程序?   java如何在程序中显示字符串的完整信息。反恐精英?   java在Hibernate中从持久性上下文中分离实体中的实体