Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Feb 24, 2010 1:04 pm 
Offline
Senior Newbie

Joined: Thu Feb 04, 2010 12:35 pm
Posts: 13
Location: Toronto, Ontario
Is there a way to set up postfix to forward but also deliver? After following the Postfix with Courier and MySQL on Ubuntu 9.10 guide I added values into the forwardings table and tried sending mail. The mail is being properly forwarded.

However, I have some forwardings that are like username@mydomain.com -> username@gmail.com, and in this case, I want the mail to be forwarded to gmail but also be delivered locally, but right now it just forwards and does not retain a copy. How can I get that to happen?


Top
   
 Post subject:
PostPosted: Wed Feb 24, 2010 1:28 pm 
Offline
Senior Member

Joined: Fri Dec 07, 2007 1:37 am
Posts: 385
Location: NC, USA
I've never used it, but it seems like this might help:

http://www.postfix.org/ADDRESS_REWRITIN ... l#auto_bcc


Top
   
 Post subject:
PostPosted: Fri Feb 26, 2010 1:58 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
Or if procmail is being used to deliver local mail, you could put something like the following in ~/.procmailrc for the user in question:
Code:
: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.


Top
   
 Post subject:
PostPosted: Mon Mar 01, 2010 7:53 pm 
Offline
Senior Newbie

Joined: Thu Feb 28, 2008 1:29 pm
Posts: 19
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'.


Top
   
 Post subject:
PostPosted: Tue Mar 02, 2010 11:53 am 
Offline
Senior Member

Joined: Fri Dec 07, 2007 1:37 am
Posts: 385
Location: NC, USA
skavoovie wrote:
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

The OP was using mysql lookups for virtual_alias_maps, so I wasn't sure if they could have multiple entries (I don't use mysql).


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group