danil-smirnov / docker-postfix

Postfix Docker image with SMTP authentication, TLS and OpenDKIM support
MIT License
17 stars 3 forks source link

Example of a custom configuration script (configure.sh) #8

Open katefike opened 2 years ago

katefike commented 2 years ago

Hello!

Can you provide an example of what a customer configuration script might look for this image? Thanks!

danil-smirnov commented 2 years ago

Hey,

It's in README already - see item 6.

If you put the following code in e.g. /home/user/postfix.sh file:

postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
echo "mailbox@${MAIL_DOMAIN} address@domain.com" > /etc/postfix/virtual
postmap /etc/postfix/virtual

And then you run the container with the file mounted:

$ docker run -p 25:25 \
    -e MAIL_DOMAIN=example.com -e MAIL_HOST=mail.example.com -e SMTP_USER=user:pwd \
    -v /home/user/postfix.sh:/configure.sh \
    --name postfix -d danilsmirnov/postfix

a postfix alias will be created to forward emails arriving at mailbox@${MAIL_DOMAIN} to another mailbox address@domain.com.