1

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

  • 2
    I don't know if postfix will duplicate mail for multiple users, but if you do not find a solution this is easily done with procmail (which gets run after postfix receives the mail) – Angelo Oct 20 '14 at 13:52
  • 1
    I couldn't help thinking "mailing lists" when I read this question... – John WH Smith Oct 20 '14 at 16:15
  • thx Angelo. procmail did the trick. – harp Oct 21 '14 at 11:21
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.

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
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.