spamclib
A SPAMC protocol library.Help you use SpamAssassin's SPAMD service.
Feature support
- Support sync client.
- Support async client.
- Support TLS.
Install
pip install spamclib
Example
Sync client
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from spamclib.spamc_sync_client import SyncSpamcClient
GTUBE = '''
Subject: Test spam mail (GTUBE)
Message-ID: <GTUBE1.1010101@example.net>
Date: Wed, 23 Jul 2003 23:30:00 +0200
From: Sender <sender@example.net>
To: Recipient <recipient@example.net>
Precedence: junk
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
This is the GTUBE, the
Generic
Test for
Unsolicited
Bulk
Email
If your spam filter supports it, the GTUBE provides a test by which you
can verify that the filter is installed correctly and is detecting incoming
spam. You can send yourself a test mail containing the following string of
characters (in upper case and with no white spaces and line breaks):
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
You should send this test mail from an account outside of your network.
'''
if __name__ == '__main__':
sc = SyncSpamcClient()
# ping cannot support SpamAssassinForWindows
sc.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
Async client
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import asyncio
from spamclib.spamc_async_client import AsyncSpamcClient
GTUBE = '''
Subject: Test spam mail (GTUBE)
Message-ID: <GTUBE1.1010101@example.net>
Date: Wed, 23 Jul 2003 23:30:00 +0200
From: Sender <sender@example.net>
To: Recipient <recipient@example.net>
Precedence: junk
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
This is the GTUBE, the
Generic
Test for
Unsolicited
Bulk
Email
If your spam filter supports it, the GTUBE provides a test by which you
can verify that the filter is installed correctly and is detecting incoming
spam. You can send yourself a test mail containing the following string of
characters (in upper case and with no white spaces and line breaks):
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
You 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 SpamAssassinForWindows
loop.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
License
MIT License
Thanks
Part of the project reference aiospamc Thanks mjcaley
Metadata
Release files for spamclib 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spamclib-0.0.3.tar.gz | 8.0 kB | Without provenance | Details for spamclib-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spamclib-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for spamclib-0.0.3-py3-none-any.whl |
Total release size: 18.5 kB
Release files / spamclib-0.0.3.tar.gz
| Download URL | spamclib-0.0.3.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9387014856139767b88d8228dad12ecf1bbf23cd4d867a6f500defc3c27111f4
|
|
BLAKE2b-256 checksum How to use checksums |
5d3b6d69f659cdb5e66db2fa79a52bbfa388557f45f99e9027b994de28ed51aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0
|
Release files / spamclib-0.0.3-py3-none-any.whl
| Download URL | spamclib-0.0.3-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ba86be8343611fb9076bb73c23da08b2a404e401554ec90f814c8cd7bf4443b
|
|
BLAKE2b-256 checksum How to use checksums |
78b5d07187a7913989e6147b2cfdd7d58d03fe209954bd091ca895facb2a7642
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0
|
Security for spamclib 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.