In all examples, `podman` can be replaced directly with `docker`.
## Supported environment variables
### Generic variables
-`DEBUG=[0|1]` Enables "set -x" in the entrypoint script.
-`TZ` Timezone to use in the container.
### SMTP related variables
-`SERVER_HOSTNAME` Server hostname. Emails will appear to come from the hostname's domain.
-`SERVER_DOMAIN` If not set, the domain part of `SERVER_HOSTNAME` will be used.
-`SMTP_RELAYHOST` Name of the SMTP relay server to use.
-`SMTP_PORT=587` The relayhost port.
-`SMTP_USERNAME` Username to authenticate with on the relayserver.
-`SMTP_PASSWORD` Password of the SMTP user, alternative `SMTP_PASSWORD_FILE` could be used to point to a file with the password
-`SMTP_NETWORKS` Comma seperated subnets who are allowed to use the relay. E.g. `SMTP_NETWORKS='xxx.xxx.xxx.xxx/xx, xxx.xxx.xxx.xxx/xx'`. 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are preset.
-`INET_PROTOCOLS` The network interface protocols used for connections. Valid values are "all", "ipv4", "ipv6" or "ipv4,ipv6". The default value is "ipv4".
-`MASQUERADE_DOMAINS` Comma separated list of domains that must have their subdomain structure stripped off.
-`MYDESTINATION` List of domains for which mails are delivered locally instead of forwarding to another machine.
-`NULLCLIENT=[0|1]` Don't accept any mails locally but relay them to a remote host. Ignored if `MYDESTINATION` is set. The default is `1`.
-`SMTP_TLS_SECURITY_LEVEL` SMTP TLS security level. The default is `may`.
-`LMTP=host` Host on which the lmtp service is running. This will disable the usage of the vmail user account.
### Accepting mails on port 587 (submission) and 465 (submissions/smtps)
-`ENABLE_SUBMISSION=[0|1]` Enable submission port. The default is `0`.
-`ENABLE_SUBMISSIONS=[0|1]` Enable submissions/smtps port. This requires `SMTPD_USE_TLS=1`. The default is `0`.
-`SMTPD_USE_TLS=[0|1]` Enforce TLS. The default is `0`.
-`SMTPD_TLS_CRT=` Path to certificate, default `/etc/postfix/ssl/certs/tls.crt`
-`SMTPD_TLS_KEY=` Path to public key, default `/etc/postfix/ssl/certs/tls.key`
### Virtual mailbox related variables
-`VIRTUAL_MBOX=[0|1]` Create virtual mail boxes in /var/spool/vmail owned by user vmail.
-`VMAIL_UID=5000` User ID and group ID of the vmail user for virtual domains and mailboxes.
-`VIRTUAL_DOMAINS=` Whitespace seperated list of virtual domains, will be written to `/etc/postfix/vhosts`.
-`VIRTUAL_USERS=` Whitespace seperated list of virtual users email addresses.
### LDAP related variables
-`USE_LDAP=[0|1]` Use LDAP for virtual mail box user accounts.
-`LDAP_BASE_DN` LDAP base DN, defaults to `dc=example,dc=org`.
-`LDAP_SERVER_URL` LDAP Server URL, defaults to `ldap://localhost`.
-`LDAP_BIND_DN` DN to bind, defaults to `cn=mailAccountReader,ou=Manager,dc=example,dc=org`
-`LDAP_BIND_PASSWORD` The password for the distinguished name to bind (`LDAP_BIND_DN`)
-`LDAP_USE_TLS=[1|0]` Use TLS for LDAP queries, by default enabled.
-`LDAP_TLS_CA_CRT` LDAP SSL CA certificate.
## Data persistence volumes
-`/var/spool/postfix` Postfix mail queues. A data volume should be used in order to save the queue content if the container restarts.
-`/var/spool/vmail` Virtual user mboxes. This directory contains the mails stored in Maildir format of the virtual users of the virtual domains. Everything is owned by the `vmail` user.
-`/etc/pki` PKI directories for CA certificates
## Virtual domains and virtual users
The environment variable `VIRTUAL_MBOX=1` will enable support for virtual
domains and virtual users. It can be used in conjunction with a relay host.
Mails for virtual domains and users are stored in Maildir format in
`/var/spool/vmail` inside the container. To not loose the mail, this directory
should be a persistence volume.
`VMAIL_UID` specifies the UID and GID which owns all files below this
directory. This makes sure, that the container is using the same UID/GID as
the Container Host OS for the files and not regular users are owning this
files and can read and modify them. The default UID/GID is `5000`.
There are three ways to provide the data for virtual domains and users, via
environment variables, files or LDAP.
### Environment Variables
Beside the already mentioned environment variables, two futher variables
define the virtual domains and the virtual users.
`VIRTUAL_DOMAINS="example.com example2.com example3.com"` is a whitespace
seperated list which can contain one or more virtual domains. For every
domain, an own directory below `/var/spool/vmail` will be created.
With LDAP (use `VIRTUAL_MBOX=1` and `USE_LDAP=1`) the postfix schema is used: `maildrop` is the real email address, while `mailacceptinggeneralid` are aliases.
If the `VIRTUAL_DOMAINS` environment variable is not set, the virtual domains are take from the email addresses used in `mailacceptinggeneralid`. In this case,
the email domains of the aliases must be different then the one of `maildrop`. If the virtual domains are specified with `VIRTUAL_DOMAINS`, `mailacceptinggeneralid`
are handled as normal mail aliases and the domain could be the same as for `maildrop`.
## Mail delivery via LMTP
To deliver the mails via a LMTP service, the container needs to know the host