Postfix/mysql forward and deliver
Postfix with Courier and MySQL on Ubuntu 9.10 guide
However, I have some forwardings that are like
4 Replies
:0Hc
* !^X-Loop: YOURGMAILNAME@gmail.com
{
# Avoid potential mail loops
:0 fwh
| formail -A"X-Loop: YOURGMAILNAME@gmail.com"
# Forward to the other account
:0
! YOURGMAILNAME@gmail.com
}
Disclaimer: I haven't tested this, stole it from here
The method used depends upon whether original the destination address is a real system user or not (assuming a fairly default Postfix environment).
If the local recipient user is a real system account on your server, modify your aliases file (default: /etc/aliases), and add an entry for the user.
Say the user's system/shell account is 'someuser', and you want a copy sent to the user on the local machine, and a copy sent to
someuser: someuser someaccount@gmail.com
Save your changes, close the file, and update db file used by Postfix by issuing the following command:
newaliases
If the recipient address is not an actual system account, but instead is just a virtual user locally using a virtual domain, the easiest way to do this is to rely upon the virtual file – the default is /etc/postfix/virtual, but is whatever file is declared by the virtualaliasmaps value in your main.cf
Say the recipient email address is
someuser@somedomain.com acct@domain2.com acct2@gmail.com
All one line. Save your changes, close the file, and then issue the command:
postmap /etc/postfix/virtual
to update the db file used by Postfix, using whatever file you have configured Postfix to use and just edited.
This of course assumes that domain2.com was setup as a local virtual mailbox domain, is NOT listed as a virtualaliasdomain, and that somedomain.com is defined in either virtualaliasdomain or in mydestination parameters in main.cf so that Postfix will know to accept mail authoritatively for those domains.
In other words, this all assumes you've properly configured your Postfix MTA otherwise. Be sure you run 'newaliases' and/or 'postmap' as root, or if you're using a Distro that gimps the root account, run it with root permissions using 'sudo'.
@skavoovie:
If the recipient address is not an actual system account, but instead is just a virtual user locally using a virtual domain, the easiest way to do this is to rely upon the virtual file – the default is /etc/postfix/virtual, but is whatever file is declared by the virtualaliasmaps value in your main.cf
The OP was using mysql lookups for virtualaliasmaps, so I wasn't sure if they could have multiple entries (I don't use mysql).