Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The FAQ tip at seems to rely on the fact that the following entry in virtusertable:   user+%1

will cause $1 in the .procmailrc config, e.g.:


to have the value "xyz" if email received was for and "abc" for (Viewing the procmail log seems to confirm this.)

However, I'd like to have $1 have the value "" instead. This is so I can do processing for multiple domain names under the same user.

The following virtusertable/.procmailrc config seems to work for this purpose:

virtusertable:   userA+%1\   userA+%1\



* ENV_TO ?? .
| formail -i "X-Envelope-To: $ENV_TO"

| formail -i "X-Envelope-To: UNKNOWN"

* ^X-Envelope-To: xyz\\

* ^X-Envelope-To: abc\\

However, I'd like to avoid having to the double backslashes appear in X-Envelope-To. Removing [what seems to be] the quoting backslash in the virtusertable fails, e.g.:

seems to cause an "excessive recursion error".

My question is:

How does one properly quote the at-sign in virtusertable, so that $1 that arrives in .procmailrc will only contain "" rather than "abc\"?

Or, if that is not possible, how can we remove the backslash within .procmailrc processing itself so that ENV_TO is (ultimately) assigned "" rather than "abc\"?

share|improve this question
The ambersand is &. I think you mean the % (percent) sign. – adamo Apr 27 '12 at 14:53
You're right, thanks for spotting the error, I meant the at-sign not ampersand. – Andz May 3 '12 at 7:27

You make your virtusertable read like: and then you make a script that reads the X-Envelope-To: header prepared from formail which replaces it with the proper value. In other words, you need your own version of formail just for this purpose. You can do that even with your current setup where you will have the script parse the X-Envelope-To: header and remove the backslash.

share|improve this answer
I stuck with \@ because the dash might appear in %1. So my procmailrc now has X=$1; ENV_TO=echo ${X} | sed 's/\\\@/@/' to remove the backslash. Was hoping for a less elaborate solution, e.g. no need for sed, but doesn't seem like there's one? – Andz May 3 '12 at 7:25

Your Answer


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.