procmail
[Top] [All Lists]

Re: handle outgoing mail?

1997-09-10 00:46:22
When I suggested these for passing outgoing mail through procmail,

| > 1. Use procmail's -m option for outgoing mail so that the positional
| > parameters that your MUA would normally tell the MTA are passed to
| > procmail.
| >
| > 2. End your rcfile for outgoing mail with something like this so that
| > those positional parameters are told to the MTA:
| >
| >    :0
| > ! "$@"

Chris Bidmead replied,

| I do 1) but not 2) (because I don't actually call sendmail directly from  
| my outgoing procmail script, but instead call Tim Luoma's very nice  
| StopThatMail for NeXTStep).  My outgoing procmail script collects the  
| addresses (ADDRESSES=`formail -x To: -x Cc:`)

That's a somewhat different situation: your MUA apparently puts addressees
in visible places rather than in the positional parameters, and you want to
set the positional parameters to the addresses (though it seems that you
cannot send a Bcc: this way; well, that's easily cured like this:

  :0h
  ADDRESSES=|formail -zxTo: -xCc: -xBcc:

  :0hfw
  | formail -IBcc:

).  Either that or you want to clobber the positional parameters with the
addresses in the headers.

I thought of the situation where the envelope recipients are listed in head-
er lines rather than in the positional parameters, but then I figured that
for such a setup, the positional parameters will include "-t" instead of the
actual addresses.  Thus 

  :0
  ! "$@"

will still work, because it will resolve to

  :0
  ! -t

but this appears to be yet different, because you want to clobber any posi-
tional parameters set by the MUA with the addresses in the headers.

| and then passes them on in  the closing stanza like this:
| 
| :0
| |$HOME/stopthatmail -oi -odb "$ADDRESSES"

Are you sure about putting quotes around $ADDRESSES and making the whole list
into one parameter?  Maybe stopthatmail likes it that way and it's the right
thing to do.  If that's the case, "$@" won't work for you if there are more
than one recipient, and I don't know if procmail handles "$*".  So I can see
why you need to do it that way if stopthatmail wants the whole address list
as one parameter.  The MTAs with which I'm familiar do not, and neither
"$ADDRESSES" nor $ADDRESSES without quotes would work properly with them;
"$@" would.

| Effectively the same thing (I think), but it prevents that "$@"  
| parameter string getting lost in the crowd.

How would it get lost?

By the way, you could set SENDMAIL=$HOME/stopthatmail (or just
SENDMAIL=stopthatmail if $HOME is in the rcfile's $PATH) and get

  :0
  ! -oi -odb "$ADDRESSES"

In more recent versions of procmail, if the first eight characters of the
basename of $SENDMAIL are "sendmail", -oi is automatic on "!" forwarding
actions (but not on "| $SENDMAIL" pipe actions).  If you linked
$HOME/stopthatmail to $HOME/sendmail and set SENDMAIL=$HOME/sendmail,

 :0
 ! -odb "$ADDRESSES"

would be equivalent.  So the two are not really very much different.

But I still think it's odd that stopthatmail would want the entire address
list as a single parameter.  I'm going to look into "$*" and report back.

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