Worse, I haven't had any luck getting an X-Originally-To: or anything of the sort added server-side, so my only option is to pull the original address out of Received: headers. To complicate things further, the box it's being dropped into could be directly e-mailed, so that has to be accounted for as well.
My previous setup was qmail as the MTA, TMDA filtering things through my .qmail-* files. I need fetchmail/getmail/etc. to pull the messages off the POP3 server. Here's what I've come up with so far, in pseudo-code:
TO=`formail -z -c | grep @mydomain.tld | formail -U Received: -x \While this isn't a TMDA-specific question, this seems like the first place to start asking -- can this be done in a getmail or fetchmail file? I know for getmail I'll need a wrapper anyway, probably for either. Any suggestions on how I can set this up, or other routes to explore? Or should I just surrender the effort?
Received: | grep -o --regexp='<uname.*>' | sed -e 's/^.//' -e 's/.$//'`
if ($TO == "")
TO="[EMAIL PROTECTED]"
RECIPIENT=$TO
EXTENSION=`echo $TO | grep -o --regexp='-.*@' | sed -e 's/^.//' -e 's/.$//'`
| preline /usr/bin/tmda-filter
