This is an SMTP-to-Discord Webhook relay. Effectively, it's an SMTP server that listens for emails, and posts any received to a discord web hook. Just point your existing mail agents at it and it should work.
Setup pretty much just amounts to installing the dependencies from requirements.txt, optionally in a virtual environment.
If you want the server to run on startup, then you will have to find a way to create a service for your particular init system.
You can also run the script in a Docker container. See Docker Container.
smtp2discord.py [-h] [-b BIND] [-p PORT] [-H] [-f FILECMD] [-a] webhook
-aAttaches the original email file to the discord message so you can view it with a regular email client-bSets the IP address for the server to bind to.-pSets the port for the server to listen to.-HAttaches a text file containing all of the headers-fPath to the executable for thefilecommand, in case it isn't available on the path or has a different name-hDisplays help information
- The server must be run as root to listen on the default port.
- By default, the server listens on address
127.0.0.1and port25. These can be changed with the-band-poptions, respectively. - The shebang might need to be adjusted for your system
- Changing the
/usr/bin/envto whatever the output ofcommand -v envis should work - If
envisn't available on your system, then you can point it directly at thepython3executable - If you change the shebang, then be sure the point it at your virtual environment if you are using one
- Changing the
- The
filecommand is required to guess theContent-Typeheader. If it isn't available, then you might have some issues- A path to the
filecommand can be given using the-foption
- A path to the
In case you use docker, this script also supports being run as a docker container. The arguments may be passed as environmental variables.
Run a container with
docker run -d -p 25:25 -e WEBHOOK=https://webhookurl -e BIND=0.0.0.0 limeparallelogram/smtp2discord
You can also use a docker-compose file if you prefer.
services:
main:
image: limeparallelogram/smtp2discord
environment:
- WEBHOOK=https://webhookurl
- BIND=0.0.0.0
ports:
- 25:25The full list of environmental variables is as follows:
| name | description | default |
|---|---|---|
| * WEBHOOK | Provide the discord webhook url | None |
| ATTACH | Attaches the original email file to the discord message so you can view it with a regular email client | False |
| BIND | Sets the IP address for the server to bind to | 127.0.0.1 |
| PORT | Sets the port for the server to listen on (Note: This is only internal to the container. In most cases you should change the left number in the ports section) | 25 |
| SEND_HEADERS | Attaches a text file containing all of the headers | False |
| FILE_COMMAND | Path to the executable for the file command, in case it isn't available on the path or has a different name |
file |
*Indicates a required variable