0

I'm storing and forwarding (to google apps) emails using the following procmail recipe:

# set vars
USERNAME=local_username
LOCALPART=realemaillocalpart

:0
# Avoid email loops
* ! ^X-Loop: ${USERNAME}@domain\.nl
{
  :0c:   #Preserve a copy of the email
  ${DEFAULT}
  :0fwh  #Adjust some headers before forwarding
  | formail -A"X-Loop: ${USERNAME}@domain.nl" \
  # Forward the email
  :0
  !${LOCALPART}@apps.domain.nl
}

This works, but when I set up an 'out of office' message in gmail it returns the email to the forwarding system instead of to the original sender.

This probably has to do with the forwarding system adding or replacing a Return-path line and putting the local username and the servername in there.

My question is thus how can I prevent that from happening?

datadevil
  • 525
  • 1
  • 6
  • 22
  • The Return-Path header is added by the LDA on delivery, not by Procmail. If your local Sendmail equivalent allows you to set the envelope sender with `-f` and you have access to this information (perhaps by extracting the Return-Path header on the system where you run Procmail) that should fix the problem, provided your diagnosis is correct. – tripleee Jul 22 '12 at 19:36

1 Answers1

0

Try

# Forward the email
:0
* ^Return-Path:[  ]*\/[^  ].+
{ env=$MATCH }
:0
! ${env+-f "$env"} ${LOCALPART}@apps.domain.nl

As is customary in Procmail recipes, the whitespace inside the square brackets should consist of a space and a tab (both places where the Return-Path header is being matched. I could not write literal tabs from the mobile device I'm typing on).

tripleee
  • 1,324
  • 3
  • 14
  • 24
  • 1
    thanks, worked like a charm! Not sure what went wrong at first, retried editing it from scratch and now it works. – datadevil Aug 14 '12 at 07:20
  • I have the same problem as datadevil that Return-Path is modified after piping through procmail. I tried your solution @tripleee, but procmail says there's no match. – joshu Mar 30 '13 at 02:14
  • No match could mean either that there is no Return-Path: header, or that you mistyped the regex somehow. – tripleee Mar 30 '13 at 08:18
  • @tripleee hi. there is a Return-Path header. I copy and pasted your code as I wanted to avoid mistyping ;) – joshu Mar 30 '13 at 11:03
  • Check that the whitespace in `[ ]` and `[^ ]` is a space and a tab. Copy/pasting from a web page might not work correctly, as indicated already in the original answer. – tripleee Mar 30 '13 at 11:29
  • @tripleee Maybe it's an issue with using the vi editor, but I've written your code from scratch in vi on the server and it doesn't match. No worries I'll look for another solution. – joshu Mar 30 '13 at 11:51