This is simple to do with Postfix natively -- no need to rely upon any add-ons or external apps such as procmail.
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
someaccount@gmail.com, you would specify the following:
Code:
someuser: someuser someaccount@gmail.com
Save your changes, close the file, and update db file used by Postfix by issuing the following command:
Code:
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 virtual_alias_maps value in your main.cf
Say the recipient email address is
someuser@somedomain.com, which is then routed to a local virtual alias on your server of
acct@domain2.com, and you want that local user to receive a copy and a copy to also be sent to
acct2@gmail.com. Your /etc/postfix/virtual changes would look like this:
Code:
someuser@somedomain.com acct@domain2.com acct2@gmail.com
All one line. Save your changes, close the file, and then issue the command:
Code:
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 virtual_alias_domain, and that somedomain.com is defined in either virtual_alias_domain 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'.