2

I'd like to know if it is possible to configure postfix to redirect to many email addresses (including the original recipient) instead of only one?

Here is my scenario: When an e-mail is:

Sent from: user@isp.com

Addressed to: user@ourcompany.com

Result: redirect e-mail to user2@ourcompany.com and deliver to the original recipient

The question is partly answered here: https://serverfault.com/questions/284702/redirect-specific-e-mail-address-sent-to-a-user-to-another-user

harp
  • 1,027

2 Answers2

1

Use an alias like this:

user: user, user2

According to the local(8) man page:

When an address is found in its own alias expansion, delivery is made to the user instead.

So you don't get infinite recursion.

Barmar
  • 9,927
1

I fixed the problem with procmail.

Source: http://www.netikka.net/tsneti/info/proctips.php#forward

Below is an example:

#Get the sender's bare email address from the first "From" line
FROM_=`formail -c -x"From " \
         | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g' \
         | awk '{ print $1 }'`

#Get the original subject of the email
#Discard superfluous tabs and spaces
#On some systems -xSubject: has to be -x"Subject: "
SUBJ_=`formail -c -xSubject: \
         | expand \
         | sed -e 's/  */ /g' \
         | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`

#Whatever other recipes you'll use

:0
* ^From:.*infolist@([-a-z0-9_]+\.)*infohost\.infodom
# Avoid email loops
* ! ^X-Loop: myid@myhost\.mydom
{
  :0c:   #Preserve a copy of the email
  Infolist.mail
  :0fwh  #Adjust some headers before forwarding
  | formail -A"X-Loop: myid@myhost.mydom" \
            -A"X-From-Origin: ${FROM_}" \
            -i"Subject: $SUBJ_ (fwd)"
  # Forward the email
  :0
  !mydept@myhost.mydom
}
harp
  • 1,027