Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 Answer 1

up vote 0 down vote accepted

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).

share|improve this answer
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 7: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 2: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 8: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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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