procmail
[Top] [All Lists]

Re: Help needed

1997-04-22 03:14:00
On Tue, 22 Apr 1997 09:02:46 +0200 (MET DST),
Bernard El-Hagin <sokrates(_at_)next(_dot_)eti(_dot_)pg(_dot_)gda(_dot_)pl> 
wrote:
 I'm new not only to Procmail, but to this list as well, so I hope someone
 will be able to help me out.

I hope you have noticed that there are several manual pages for
different purposes. Check out the procmailex(5) man page for various
examples, many of them fairly close to what you are asking about. 
 
I. If <condition> than:

Do you want to do all of the following, or examples of how to do each?

  1) delete the message completely (I'm not an admin so I can't use
  /dev/null), 

Sure you can. 

:0
* <condition>
/dev/null

  2) bounce message back to sender,

:0
* <condition>
{
    EXITCODE=67 HOST
}

This will terminate Procmail with an exit code of 67. This exit code
is passed back to Sendmail which produces a bounce message. The
significance of the exit code can be gleaned from the file
/usr/include/sysexits.h on most systems. 

  3) bounce message back and attach a message from me (where do I store
the message to send with the bounced mail),

:0
* <condition>
| ( formail -rtk ; cat $HOME/bug-off.txt ) | $SENDMAIL $SENDMAILFLAGS -t

The expression in parentheses generates a message which is passed back
to Sendmail and sent off. The formail part generates a reply from the
original message and quotes the body of the original. (Leave out the k
flag from -rtk if you don't want this.) The second part, the cat,
appends the message from a file called bug-off.txt in your home
directory. You can keep this file anywhere you like (as long as you
have suitable permissions) -- just remember to tell Procmail the full
pathname. 
  For a slightly more complicated example involving a shell script,
check the archive of this mailing list for a message to Catherine
Hampton from last Thursday or Friday. The archive is at

    <http://www.rosat.mpe-garching.mpg.de/mailing-lists/procmail/>

You can find lots of other good examples just by browsing the archive,
by the way. 

II. Delete message if it's more than n-lines, but _not_ if it's From:
<someone>.

:0
* ! ^From: <someone>
* > n
/dev/null

Here, n is actually the number of bytes in the message (header +
body). Check out the scoring system (man procmailsc) for rather more
advanced techniques if this is not acceptable.

III. Is it possible to remove a header off an e-mail _before_ sending it
to someone (like sending a mail without the From )?

You cannot send a message without a From_ line -- this is not even
part of the message headers so the question is a bit off. 
  In principle, however, there is nothing to stop you from hooking
Procmail into your outgoing mail, if you can figure out how. Some mail
clients let you do, uh, things to messages before they are sent. You
could write your own mail sending wrapper. You could send messages to
yourself with a special keyword that your .procmailrc could pick up
and react on. 
  But for a simple answer, no, there is nothing like a `.backward'
file where you can plonk in Procmail like you can in your .forward
file for incoming mail.

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

<Prev in Thread] Current Thread [Next in Thread>
  • Help needed, Bernard El-Hagin
    • Re: Help needed, era eriksson <=