procmail
[Top] [All Lists]

Re: Can someone else help Brian Dupras, please?

2001-08-31 21:43:31
On 31 Aug, David W. Tamkin wrote:
| Last night we had heavy storms, and our house has a lot of flood damage.
| Goodness knows when I will be able to post the code I promised to Brian
| Dupras yesterday for his resending question.
| 
| Would someone else please step in and illustrate how to filter the head
| through
| 
|   formail -ITo: -I "From: $LOGNAME(_at_)$HOST" -X ""
| 
| and deliver the message (or a copy) to
| 
|   ! -t
| 
| so that messages he sends to his other account can be remailed from it to
| the addresses in To:, Cc:, or Bcc: lines at the top of the body?  Thank you
| so much.
| 

I used to do something similar, but in a different way than David
described. Let's start with that, then try to adapt it closer to
David's method. That'll allow me to start with something familiar,
and show two possible ways to accomplish the task.

I used this to relay mail from home before I had a "real" mail
server through my ISP and on to the final destination to get around
various roadblocks (e.g. DUL,RBL,unresolvable domain). (The ISP accepted
mail from my machine since it was their IP, and to the final destination
it "originated" from the ISP which was ok.)  If I wanted to mail
something to sis(_at_)aol(_dot_)com, I composed the message as usual but mailed 
it
to myself at the ISP, and in the Subject: included 
[mailto:sis(_at_)aol(_dot_)com](_dot_)
When it arrived at aol, the part between brackets was removed and the
rest of Subject: was intact. So it would leave my home machine looking
like:

To: deh(_at_)myisp(_dot_)com
Subject: Happy Birthday [mailto:sis(_at_)aol(_dot_)com]

and at myisp.com it would get transformed and mailed as:

To: sis(_at_)aol(_dot_)com
Subject: Happy Birthday


:0
* [ enough conditions here to make it highly
*   unlikely that anybody abuses the facility ]
* ^Subject:.*\[mailto:.*\]
{
  NEWTO=`formail -x 'Subject:' |sed 's/.*\[ *mailto: *\([^]]*\)\].*/\1/'`
  SUBJ=`formail -x 'Subject:' |sed 's/ *\[mailto: *[^]]*\]//'`
  :0 fwh
  | formail -I "Subject: $SUBJ" -I "To: $NEWTO"
}
:0 A
! $NEWTO

[All this could be done without sed, but this is pretty much the same
recipe I used a number of years ago.]

I gather that you would need to also change the From: header, so let's
try to adapt this to something closer to David's implementation and
include that header change. Using your original description:

:0
* [ enough conditions here to make it highly
*   unlikely that anybody abuses the facility ]
* From: me(_at_)my(_dot_)work(_dot_)com
* B ?? ^^To:[   ]*[^    ]+(_at_)[^      ]+[     ]+passphrase
* B ?? ^^To:[   ]*\/[^  ]+(_at_)[^      ]+
{
  NEWTO=$MATCH
  :0 fwh
  | formail -I "To: $NEWTO" -I "From: me(_at_)my(_dot_)house(_dot_)com"
}
:0 A
! $NEWTO

[As usual, a space and a tab are in each of the bracket enclosed
character classes above.]

It's untested, but with this you should be able to send a message From:
me(_at_)my(_dot_)work(_dot_)com To: me(_at_)my(_dot_)house(_dot_)com, and have 
it resent from there as
From: me(_at_)my(_dot_)house(_dot_)com To: 
friend(_at_)somewhere(_dot_)else(_dot_)com, by putting

To: friend(_at_)somewhere(_dot_)else(_dot_)com passphrase

as the first line in the body of the message. It must be the first
line (required by ^^), and I'd suggest you want that to eliminate full
body searches.  You would want to set passphrase to something of your
choosing (in both the message and the recipe condition), or you could
eliminate it and the condition that looks for it if you thought it
unnecessary. It's intended as a little extra precaution against abuse.
This will only work with one recipient. If that's not good enough, the
regular expression(s) in the B(ody) conditions will need some work.

In your original message you mentioned sending to 
resend(_at_)my(_dot_)house(_dot_)com(_dot_)
I'm guessing that you figured a separate account was necessary, but
it's not. If I misunderstood and you do want to do this through a
different account, that'll need to be changed where appropriate. And if
you want to be able to use the same recipe on multiple accounts and or
machines at home, change the hard coded me(_at_)my(_dot_)house(_dot_)com to
$LOGNAME(_at_)$HOST as David indicated.  That assumes your MTA appends the
domain name, otherwise you'll probably want to add that too. I don't
know what he was getting at with the -X "" option to formail, so I'll
leave that to him when he gets time. Hopefully this is at least
something close to what David intended, and is some help.

(Sorry to hear of your troubles, David.)

-- 
                   /"\
Don Hammond        \ /     ASCII Ribbon Campaign
Raleigh, NC US      X        Against HTML Mail,
                   / \      and News Too

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>