spamtraps package

Submodules

spamtraps.aioimap_collector module

class spamtraps.aioimap_collector.AsyncIMAPCollector(protocol, host, port, username, password, fetch_all=False, delete=False, continuous_fetch=True)

Bases: object

CHECK_TIMEOUT = 3
INBOX = 'INBOX'
MAILSTATE = 'UNSEEN'
START_TIMEOUT = 5
async check_mailbox(queue)
check_msg_count(info_list)
async connect()
async static fetch_and_queue(imap_client, items, queue)
async wait_for_new_message(imap_client, queue)
class spamtraps.aioimap_collector.CollectorManager(feed_config, mailbox_config, fetch_all=False, delete=False, continuous_fetch=False)

Bases: object

async harvest()
read_account_config(account_config, fetch_all, delete, continuous_fetch)
static read_config(path_to_config)

spamtraps.aiolmtp_collector module

class spamtraps.aiolmtp_collector.CustomLMTPHandler(queue=None, maildir_path=None)

Bases: object

async handle_DATA(server, session, envelope)
inbox = 'inbox'
store(data)
class spamtraps.aiolmtp_collector.LMTPController(handler: Any, hostname: str | None = None, port: int = 8025, loop: AbstractEventLoop | None = None, **kwargs)

Bases: Controller

Implementation of the aiosmtpd Controller to create an LMTP server.

factory()

Subclasses can override this to customize the handler/server creation.

spamtraps.message_distributor module

class spamtraps.message_distributor.AMQPDistributor(host='localhost', port=5671, vhost='/', ident='writer', secret='secret', exchange=['spam'], routing_key='spam.mails', tls=True, check_cert=True)

Bases: MessageDistributor

async distribute_queued(queue)
async establish_connection()
class spamtraps.message_distributor.HpfeedsDistributor(host='0.0.0.0', port=10000, ident='writer', secret='secret', channels=['spam.mails'], tls=True)

Bases: MessageDistributor

async distribute_queued(queue)
class spamtraps.message_distributor.MessageDistributor

Bases: ABC

MAX_RETRIES = 10
RETRY_INTERVAL = 1
abstract distribute_queued(queue)
static get_distributor(_type, **kwargs)
static populate_distributors()

spamtraps.run_collector module

spamtraps.run_collector.customize_aioimaplib_logger(formatter, file_log=None)
spamtraps.run_collector.get_imap_args()
spamtraps.run_collector.get_lmtp_args()
spamtraps.run_collector.log_config(args)
spamtraps.run_collector.read_config(path_to_config)
spamtraps.run_collector.register_signals(loop)
spamtraps.run_collector.run_imap_collector()
spamtraps.run_collector.run_lmtp(port, maildir, conf)
spamtraps.run_collector.setup_logging(file_log=None, customize_aioimaplib=False)
async spamtraps.run_collector.shutdown(signal, loop)

Cleanup tasks tied to the service’s shutdown.

Module contents