exim-docker/readme.md

60 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2024-12-10 16:40:17 +01:00
# EXIM4 from Debian in a container
This image can be used to deploy an MTA in a container and connect it to a smarthost to provide the
option to send mail from other containers without the need to configure the smarthost in each of them.
## Configuration
Four environment variables are used to configure the container:
* `SMARTHOST`: The is the name of the smarthost. exim within this container will send all mail to this smarthost for further delivery. Make sure the smarthost accepts mail from this container without authentication.
2024-12-21 14:33:11 +01:00
* `SMARTHOST_USER`: Login for smarthost. If no authentication is required, skip it.
* `SMARTHOST_PASS`: Password for smarthost.
* `LOCALMAILNAME`: The domain name which shall be used as the domain part of the sender address in every outgoing mail. If not required, skip it.
2024-12-10 16:40:17 +01:00
* `RELAYNETS`: Networks exim in this container accepts for relaying. Separate multiple networks by semicolon.
2025-02-28 20:15:24 +01:00
* `WHITELISTED_RECIPIENT`: Colon-separated list of whitelisted recipient domains, if empty no recipient restrictions will be applied
2024-12-10 16:40:17 +01:00
## Deployment
Typically, don't expose the smtp port of this container to the default network of your Docker installation, otherwise it conflicts with a local MTA on the machine and it would be visible outside of the machine. Create a dedicated docker network, use that one as the default network for this container and connect other containers to that network. Afterwards, you can use the name of this container as smarthost address in the other containers.
## Example start script
```
#!/bin/bash
2025-02-28 20:15:24 +01:00
IMAGE=quay.io/wollud1969/exim-docker:0.3.2
2024-12-10 16:40:17 +01:00
MAILER_NETWORK=mailer-network
docker network create $MAILER_NETWORK || echo "mailer-network already exists"
if [ "$RELAYNETS" = "" ]; then
RELAYNETS=`docker network inspect $MAILER_NETWORK --format '{{ (index .IPAM.Config 0).Subnet }}'`
fi
docker run \
-d \
2024-12-10 16:43:49 +01:00
-e SMARTHOST=smarthost.example.com \
2024-12-10 16:40:17 +01:00
-e LOCALMAILNAME=krohne.com \
-e RELAYNETS=$RELAYNETS \
2025-02-28 20:15:24 +01:00
-e WHITELISTED_RECIPIENT="example-recipients.com" \
2024-12-10 16:40:17 +01:00
--network $MAILER_NETWORK \
--name mailer \
--restart always \
$IMAGE
```
2024-12-10 16:42:35 +01:00
## Usage in other containers
Connect other containers to the mailer network:
```
docker network connect mailer-network name_of_other_container
```
Now you can use the name of the mailer container, here `mailer` as smarthost name in that other container.
2024-12-10 16:40:17 +01:00
2024-12-21 14:33:11 +01:00