Skip to main content

aiospamc

pypi docs license unit integration python

aiospamc is a client for SpamAssassin that you can use as a library or command line tool.

The implementation is based on asyncio; so you can use it in your applications for asynchronous calls.

The command line interface provides user-friendly access to SpamAssassin server commands and provides both JSON and user-consumable outputs.

Documentation

Detailed documentation can be found at: https://aiospamc.readthedocs.io/

Requirements

  • Python 3.11 or higher

  • certifi for updated certificate authorities

  • loguru for structured logging

  • typer for the command line interface

Examples

Command-Line Tool

aiospamc is your interface to SpamAssassin through CLI. To submit a message for a score, use:

# Take the output of gtube.msg and have SpamAssasin return a score
$ cat ./gtube.msg | aiospamc check
1000.0/5.0

# Ping the server
$ aiospamc ping
PONG

Library

import asyncio
import aiospamc


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.
""".encode("ascii")


# Ping the SpamAssassin server
async def is_alive():
    pong = await aiospamc.ping()
    return True if pong.status_code == 0 else False

asyncio.run(is_alive())
# True


# Get the spam score of a message
async def get_score(message):
    response = await aiospamc.check(message)
    return response.headers.spam.score, response.headers.spam.threshold

asyncio.run(get_score(GTUBE))
# (1000.0, 5.0)


# List the modified headers
async def list_headers(message):
    response = await aiospamc.headers(message)
    for line in response.body.splitlines():
        print(line.decode())

asyncio.run(list_headers(GTUBE))
# Received: from localhost by DESKTOP.
#         with SpamAssassin (version 4.0.0);
#         Wed, 30 Aug 2023 20:11:34 -0400
# From: Sender <sender@example.net>
# To: Recipient <recipient@example.net>
# Subject: Test spam mail (GTUBE)
# Date: Wed, 23 Jul 2003 23:30:00 +0200
# Message-Id: <GTUBE1.1010101@example.net>
# X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on DESKTOP.
# X-Spam-Flag: YES
# X-Spam-Level: **************************************************
# X-Spam-Status: Yes, score=1000.0 required=5.0 tests=GTUBE,NO_RECEIVED,
#         NO_RELAYS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no
#         version=4.0.0
# MIME-Version: 1.0
# Content-Type: multipart/mixed; boundary="----------=_64EFDAB6.3640FAEF"

Metadata

Release files for aiospamc 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiospamc 1.3.1
File Size Uploaded Provenance Actions
aiospamc-1.3.1.tar.gz 23.1 kB With provenance Details for aiospamc-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiospamc 1.3.1
File Interpreter ABI Platform Actions
aiospamc-1.3.1-py3-none-any.whl Python 3 none any Details for aiospamc-1.3.1-py3-none-any.whl

Total release size: 50.1 kB

Release files / aiospamc-1.3.1.tar.gz

Download URL aiospamc-1.3.1.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
978542ff2e44276b02054b05020c5468c1a96246c770972c844137cad78f658e
BLAKE2b-256 checksum
How to use checksums
83c4f5a4c56bf3bb8e5239fca8f42318f208c7aa62ab06e5d25d2fcf059cb672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / aiospamc-1.3.1-py3-none-any.whl

Download URL aiospamc-1.3.1-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1e413ee1427ed84062601bfe453249cfba3db471b5e6d72a8dab9534524060d
BLAKE2b-256 checksum
How to use checksums
1558962171a94fd22de2017e161efeec4dae059489bdb946e460b5887b1520dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for aiospamc 1.3.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aiospamc-1.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page