0

The FAQ tip at http://www.sendmail.org/faq/section3#3.29 seems to rely on the fact that the following entry in virtusertable:

@domain.com   user+%1

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

ENV_TO=$1

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

However, I'd like to have $1 have the value "xyz@domain.com" 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:

@domain1.com   userA+%1\@domain1.com
@domain2.com   userA+%1\@domain2.com

.procmailrc:

ENV_TO=$1

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

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

:0:
* ^X-Envelope-To: xyz\\@domain1.com
$HOME/userA/domain1.com/mail/xyz

:0:
* ^X-Envelope-To: abc\\@domain2.com
$HOME/userA/domain2.com/mail/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.:

@domain1.com   userA+%1@domain1.com
@domain2.com   userA+%1@domain2.com

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 "abc@domain1.com" rather than "abc\@domain1.com"?

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

Andz
  • 101
  • 2
  • 1
    The ambersand is [&](http://en.wikipedia.org/wiki/Ambersand). 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 03 '12 at 07:27

1 Answers1

1

You make your virtusertable read like: @domain.com user+%1-domain.com 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.

adamo
  • 6,925
  • 3
  • 30
  • 58
  • 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 03 '12 at 07:25