Skip to content

Commit

Permalink
add virtual aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
maxadamo committed Sep 24, 2024
1 parent e2334e5 commit aeda9e9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ The format of this file is as-per the [`/etc/aliases`](https://linux.die.net/man

The system aliases file maps `postmaster`, `root`, `postfix` and `clamav` through to the address specified by `POSTMASTER_EMAIL`.

### Virtual Aliases

The format of this file is as-per the [`/etc/postfix/virtual`](https://www.postfix.org/VIRTUAL_README.html#virtual_alias) file.

| Configuration file (with respect to container) | If this file is present... | After modifying... |
|-----|-----|-----|
| `/etc/postfix/tables/virtual` | It is created with the defined content. | Run helper command `postconf` (see below). |

## Paths

### Required to be mapped
Expand Down
5 changes: 5 additions & 0 deletions rootfs/etc/cont-init.d/10-postfix-generate-main.cf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ CHECK_RECIPIENT_ACCESS=""
# http://www.postfix.org/postconf.5.html#alias_maps
echo "alias_maps = hash:/etc/aliases"

# https://www.postfix.org/postconf.5.html#virtual_alias_maps
if [ -f "/etc/postfix/tables/virtual" ]; then
echo "virtual_alias_maps = hash:/etc/postfix/virtual"
fi

# http://www.postfix.org/SMTPUTF8_README.html
if [ "${POSTFIX_SMTPUTF8_ENABLE}" = "true" ]; then
echo "smtputf8_enable = yes"
Expand Down
10 changes: 10 additions & 0 deletions rootfs/usr/local/bin/update_virtual_aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# shellcheck shell=bash

VIRTUAL_ALIASES_FILE="/etc/postfix/virtual"
VIRTUAL_ALIASES_FILE_LOCAL="/etc/postfix/tables/virtual"

if [ -f "${VIRTUAL_ALIASES_FILE_LOCAL}" ]; then
cat "${VIRTUAL_ALIASES_FILE_LOCAL}" > "${VIRTUAL_ALIASES_FILE}"
postmap "${VIRTUAL_ALIASES_FILE}"
fi

0 comments on commit aeda9e9

Please sign in to comment.