For example if we need to redirect all email destined for the user g to the mailbox of the user rootie we could add the following line to /etc/aliases and then run newaliases.
The /etc/aliases:
~#cat /etc/aliases # /etc/aliases g: rootie
Recreate the /etc/aliases.db Berkley DB hash used by Postfix
#newaliases
Test:
ares:~#mail g Cc: Subject: this is for rootie through g testin testin 1 2 3 rootie . #su rootie rootie$ cat ~/Maildir/new/1338216976.Vfb00I6f088M939772.ares Return-Path:X-Original-To: g@ares Delivered-To: g@ares Received: by ares.ipduh.com (Postfix, from userid 0) id DF78E4AC77; Mon, 28 May 2012 14:56:16 +0000 (UTC) To: Subject: this is for rootie through g X-Mailer: mail (GNU Mailutils 2.1) Message-Id: <20120528145616.DF78E4AC77@ares> Date: Mon, 28 May 2012 14:56:16 +0000 (UTC) From: root@ares.ipduh.com (root) testin testin 1 2 3 rootie $ exit #
Note: To send the email, exit the mail program, and get back to command prompt when sending an email from the command line use CTRL-D
OK. What about redirecting virtual mailboxes on multiple domains to the same unix account?
Upon setting the MX records for these domains add them on mydestination and virtual_alias_domains in /etc/postfix/main.cf
# cat /etc/postfix/main.cf | egrep 'mydestination|virtual_alias_domains' mydestination = ares.ipduh.com , ipduh.net , ipduh.org , ip.duh.gr , ares , localhost virtual_alias_domains = ares.ipduh.com ipduh.net ipduh.org ip.duh.grThen we need to set the path to the hash we will use in /etc/postfix/main.cf
# grep virtual_alias_maps /etc/postfix/main.cf virtual_alias_maps = hash:/etc/postfix/virtual/etc/postfix/virtual looks like:
# cat /etc/postfix/virtual someone@ares.ipduh.com rootie another@ipduh.net rootie bingo@ipduh.org rootie bogo@ip.duh.gr rootie
Finally we need to create the Berkeley DB Hash used by Postfix when mapping virtual mailboxes and maybe restart Postfix.
# postmap /etc/postfix/virtual # /etc/init.d/postfix restart Stopping Postfix Mail Transport Agent: postfix. Starting Postfix Mail Transport Agent: postfix.
Done!
Postfix user and mailbox aliases