Argh....  I've just changed apartments, and landed with an annoying internet connection which doesn't allow incoming connections.  That means my temporary e-mail arrangement, multi-dropping the domain's mail into one of my other mail accounts, is probably going to stick around for the next several months while I'm here.  :-/  That worked short-term during the move, but I'd rather have something a little more self-handling for long-term.

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 \
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
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?

Reply via email to