The main applications of virtual aliasing are:
With virtual alias domains, each hosted address is aliased to:
Virtual alias domains are not to be confused with the virtual mailbox domains. With virtual mailbox domains, each recipient address can have its own mailbox. ie If you want to store the email locally without creating a linux user each time (ie not redirect them), you need to implements virtual MAILBOX
This process is implemented with the postfix virtual domain mail delivery agent.
The aliases table provides also a system-wide mechanism to redirect mail for local recipients. You can redirect to a command. where the E-mail message is passed on standard input. See postconf.5.html and postconf.5.html
With the postconf.5.html configuration, all recipient addresses are aliased to addresses in other domains.
A virtual alias domain can not be defined:
This feature is for Postfix > 2.0 (before the domain was in the virtual_alias_table)
virtual_alias_domains = example.com ...other hosted domains...
# reload postfix /etc/postfix/main.cf
# optional only if you want to see the change immediately
postfix reload
Postfix is final destination for the specified list of virtual alias domains, that is, domains for which all addresses are aliased to addresses in other local or remote domains.
The virtual alias table is specified in the text file /etc/postfix/virtual that serves as input to the postmap command in order to output an indexed file (in dbm or db format) to speed up lookup.
Just for info because this configuration is the default and should then not be changed
virtual_alias_maps = hash:/etc/postfix/virtual
# reload postfix /etc/postfix/main.cf
postfix reload
Basically the format of this file is:
pattern address, address,
address
# comment
where:
You can see the whole file format definition at Postfix virtual alias table format
user@domain address, address, ...
user address, address, ...
When append_at_myorigin=yes, append “@$myorigin” to addresses without “@domain”
@domain address, address, ...
The result becomes the same user in otherdomain. This works only for the first address in a multi-address lookup result.
When append_dot_mydomain=yes, append .$mydomain
In this example, Mail for all other addresses in example.com is rejected with the error message “User unknown”
[email protected] postmaster
[email protected] joe
[email protected] jane
[email protected] [email protected]
# Uncomment entry below to implement a catch-all address
# @example.com jim
...virtual aliases for more domains...
# after changing the virtual file
postmap /etc/postfix/virtual
unknown_virtual_alias_reject_code default to (550) is the Postfix SMTP server reply code when a recipient address matches $virtual_alias_domains, and $virtual_alias_maps specify a list of lookup tables that does not match the recipient address.
echo -e "Subject: Virtual Aliasing with Postfix made easy \n\n This is a redirected email \n" | sendmail aliasedEmail@virtualDomain
tail -f /var/log/maillog
Jun 15 13:14:50 vps748761 postfix/pickup[25222]: 00F401FBE8: uid=1002 from=<thenico>
Jun 15 13:14:50 vps748761 postfix/cleanup[25330]: 00F401FBE8: message-id=<[email protected]>
Jun 15 13:14:50 vps748761 opendkim[24477]: 00F401FBE8: DKIM-Signature field added (s=vps748761.ovh.net, d=bytle.net)
Jun 15 13:14:50 vps748761 postfix/qmgr[25223]: 00F401FBE8: from=<[email protected]>, size=388, nrcpt=1 (queue active)
Jun 15 13:14:50 vps748761 postfix/smtp[25333]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c00::1a]:25: Network is unreachable
Jun 15 13:14:50 vps748761 postfix/smtp[25333]: Untrusted TLS connection established to gmail-smtp-in.l.google.com[173.194.76.26]:25: TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)
Jun 15 13:14:51 vps748761 postfix/smtp[25333]: 00F401FBE8: to=<[email protected]>, orig_to=<[email protected]>, relay=gmail-smtp-in.l.google.com[173.194.76.26]:25, delay=1.5, delays=0.08/0.02/0.57/0.81, dsn=2.0.0, status=sent (250 2.0.0 OK 1592219691 r14si13363181wrm.293 - gsmtp)
Jun 15 13:14:51 vps748761 postfix/qmgr[25223]: 00F401FBE8: removed
tail -f /var/log/maillog
Jun 15 12:51:28 vps748761 postfix/error[23201]: 506BB1FD27: to=<[email protected]>, relay=none, delay=0.07, delays=0.04/0.01/0/0.02, dsn=5.1.1, status=bounced (User unknown in virtual alias table)
where: