Metadata-Version: 2.1
Name: laelaps
Version: 0.0.4
Summary: Catchall email alias monitor and verifier
Author-email: Jan Maarten van Doorn <laelaps@vandoorn.cloud>
License: MPL-2.0
Project-URL: Homepage, https://github.com/JanMaartenvanDoorn/Laelaps
Keywords: catchall,email,alias,monitor,verification
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.13.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aioimaplib==1.1.0
Requires-Dist: email_validator==2.2.0
Requires-Dist: IMAPClient==3.0.1
Requires-Dist: nest_asyncio==1.6.0
Requires-Dist: numpy==2.2.1
Requires-Dist: pandas==2.2.3
Requires-Dist: pydantic==2.10.4
Requires-Dist: pydantic-settings==2.7.0
Requires-Dist: cryptography==43.0.1
Requires-Dist: structlog==24.4.0
Requires-Dist: toml==0.10.2
Provides-Extra: test
Requires-Dist: pandas-stubs==2.2.1.240316; extra == "test"
Requires-Dist: types-toml==0.10.8.20240310; extra == "test"
Requires-Dist: autoflake==2.3.1; extra == "test"
Requires-Dist: bandit==1.8.0; extra == "test"
Requires-Dist: black==24.10.0; extra == "test"
Requires-Dist: docformatter==1.7.5; extra == "test"
Requires-Dist: flake8~=7.1.1; extra == "test"
Requires-Dist: mypy==1.14.0; extra == "test"
Requires-Dist: mypy-extensions==1.0.0; extra == "test"
Requires-Dist: pydocstyle==6.3.0; extra == "test"
Requires-Dist: pyflakes==3.2.0; extra == "test"
Requires-Dist: pytest==8.3.4; extra == "test"
Requires-Dist: pytest-cov==6.0.0; extra == "test"
Requires-Dist: pylint==3.3.3; extra == "test"
Requires-Dist: pylint-gitlab==2.0.1; extra == "test"
Requires-Dist: Flake8-pyproject==1.2.3; extra == "test"
Requires-Dist: reuse==5.0.2; extra == "test"

<!--
SPDX-FileCopyrightText: 2024 Jan Maarten van Doorn <laelaps@vandoorn.cloud>

SPDX-License-Identifier: MPL-2.0
-->

# Laelaps

Laelaps is an IMAP monitoring application that is capable of verifying signed aliases. This is particularly useful when using different catchall-based aliases. Catchall-based aliases are a convenient way to generate unique email addresses for online accounts and reduce the impact of potential data leaks. However with catchall mode turned on there is a risk of attracting lots of spam.

Laelaps solves this problem by verifying whether an alias is indeed generated by the user and not by some other random party such as a spammer. This is achieved without registering the known aliases by using cryptographic signatures within generated aliases themselves. In practice a user generates an alias using a private key and the [TeumessianFox](https://github.com/Marmalade8478/TeumessianFox) browser extension and Lealaps will separate spam from emails that are send to genuine aliases. This way the user can easily generate new aliases and still be in full control of messages send to her/his inbox.

As a bonus, albeit rather experimental, Laelaps can perform other checks on incoming email messages by analyzing the message headers, these checks include:

- Verifying whether SPF, DMARC and DKIM passed.
- Possibility to register an aliases for a specific domain that is allowed to send messages only to this specific alias.
- Check wether the email was send with TLS enabled
- Check wether the sending email address exists

Laelaps moves incoming messages either to an inbox folder for messages that passed validation or to a folder that failed validation.

## Install

Run the following in your favorite python environment.

```shell
pip install laelaps
```

## Configure

Create a `config.toml` with the following contents in your working directory:

```toml
[imap]
host = "your.imap.server.host"
username = "yourImapUserName"
password = "ImapPassword"
mailbox = "FolderToMonitor"

[encryption]
# Generate yourself and keep safe!
key = "32CharacterStringEncryptionKey00"

[user]
own_domains = [ "list.of", "catchall.domains"]
target_folder_verified = "FolderToForVerifiedEmails"
target_folder_failed_validation = "FolderToForFailedVerificationEmails"
```

### Configuring using environment variables

When running Laelaps in a container, it may be useful to configure it using environment variables. If the configuration file cannot be found Laelqaps will look for the following variables:

```shell
LAELAPS_IMAP__HOST=your.imap.server.host
LAELAPS_IMAP__MAILBOX=FolderToMonitor
LAELAPS_IMAP__USERNAME=yourImapUserName
LAELAPS_IMAP__PASSWORD=ImapPassword
LAELAPS_USER__OWN_DOMAINS=list.of,own.domains
LAELAPS_USER__TARGET_FOLDER_VERIFIED=FolderToForVerifiedEmails
LAELAPS_USER__TARGET_FOLDER_FAILED_VALIDATION=FolderToForFailedVerificationEmails
LAELAPS_ENCRYPTION__KEY=32CharacterStringEncryptionKey00
```

## Run

Start laelaps with:

```shell
python -m laelaps
```

Stop laelaps with
<kbd>ctrl</kbd>+<kbd>C</kbd>

### Run with podman-compose

Make sure you have installed [Podman](https://podman.io/).
Start the laelaps container with (make sure there is a `config.toml` in the root of the project):

```shell
podman-compose up
```

Stop laelaps with
<kbd>ctrl</kbd>+<kbd>C</kbd>

Clean up with:

```shell
podman-compose down
```

## Develop

To install dev/test tools run (in the root directory)

```shell
pip install .[test]
```

Running linting and tests is done by running:

```shell
bash format.sh
```
