SMTPRD-NG
SMTP relay-daemon next-generation. Originally from https://www.hackitu.de/smtprd.
Listen locally on a predefined port for SMTP requests and relay them to another SMTP server.
A typical usecase would be to unify all local services which use email notification and let them relay through this script. This way you don't need to specify email, username and password each and everytime for locally running services.
This can also for example use msmtp. This way scripts can use sendmail which connect to smtprd-ng which relays the mail.
Additionally, we can sign and encrypt the emails with S/MIME certificates, which adds a layer of authentification and security for automated information delivery (think security notifications, logs, etc.)
For now, this is a proof-of-concept.
Features
- Relay emails received on a locally listening SMTP server
- Encrypt and sign the relayed mails (experimental)
Installation/Hacking
There is no real installation routine in place as of now. If you want to give this a try, there is a number of ways to do so:
nix (non-flakes)
Clone this repo and run nix-build .
nix (flakes)
nix run git+https://seed.radicle.garden/z3gWc1qgaeZaoGwL4WTstLNoqjayM.git -- --config config.ini
python wheel
Clone this repo and run python -m build.
Note: build must be installed. You should use a venv for this.
python (as is)
- Clone this repo
- Create a
venv - Install requirements with
pip install -r requirements.txt - Run
python smtprd_ng/smtprd.py
devenv
Clone this repo and run devenv shell
Contributing
Contributions are always welcome!
Please read https://radicle.xyz/guides/user to get used to clone this repo with radicle and submit patch or issues.
If you just want to clone the repo without radicle you can clone the repo with git clone https://seed.radicle.garden/z3gWc1qgaeZaoGwL4WTstLNoqjayM.git smtprd-ng
Beware: This is very early alpha ;-)
License
Usage/Examples
Copy config.example to config.ini and adjust to your usecase.
Run smtprd-ng --config config.ini
The script will listen on the specified port for smtp requests and forward them to the specified upstream SMTP serer.
If you want to give sign and encryption a go, you need to set
smime_cert = /path/to/cert
smime_cert_private = /path/to/cert.key
[emails]
monitoring.foo@example.com = /path/to/recipient_cert
Where
smime_certis the path to the S/MIME certificate of the sender in PEM format.smime_cert_privateis the path to the S/MIME priate key of the sender in PEM formatmonitoring.foo@example.comis the recipient and/path/to/recipient_certis the path to the certificate of the recipient in PEM format
Plese note: Right now, there is no way to set a password, so the private key is unprotected and should only be used for this automation and have appropiate file permissions. I might add the option to set a password through the config file in the future, though.
Roadmap
-
Add wheel for pypi
-
Add systemd service
-
Cleanup code