procmail
[Top] [All Lists]

Re: "Do this, then do that"

1998-07-21 18:13:33
Hi,

I am rather new at this, but following lines in the .procmailrc at
your second account should do the trick:

## start of .procmailrc lines ##

MAINACCOUNT     = "you(_at_)at(_dot_)your(_dot_)main(_dot_)account"
YOUR-X-LOOP     = "X-Loop: you(_at_)at(_dot_)your(_dot_)second(_dot_)account"

# let's keep a backup of the last 64 messages into an existing
# directory (just for safety, as indicated in procmailex(5))
# note that you must first create directory $MAILDIR/backup
:0 c    # copy messages into an existing directory
backup

# let's delete all messages but the last 64
:0 ic   # keep e.g. only the last 64 messages
| cd backup && rm -f dummy 'ls -t msg.* | sed -e 1,64d'

# now let's forward worthwile messages to your main account:
# Three conditions must be fulfilled:
# 1) let's make sure that only interesting messages are forwarded
#    to the main account (e.g. messages from someone(_at_)foo(_dot_)com)
# 2) we do not want to process messages that came back here
# 3) mailer-daemon messages must also be checked
:0
*    ^From: someone(_at_)foo(_dot_)com
*$ ! ^$YOUR-X-LOOP
*  ! ^FROM_DAEMON
| ($FORMAIL -A "$YOUR-X-LOOP" | $SENDMAIL -oi  $MAINACCOUNT )

# At this point, the forwarded message is 'consumed': it is no
# more, and you do not need to 'junk' it anymore. 
# (You must add flag c after the :0 if this is not acceptable)

# Several such blocks may be required to catch all interesting
# mail.
# If you are sure that all worthwile mail has been sent to your
# main account, you can now drop all remaining mail into the BBB
# (the Big Bit Bucket):
:0
/dev/null # or use your 'pre /dev/null' folder In.crap

# Remember, directory $MAILHOST always contains the last 64 
# messages that have arrived at your secondary account.

## end of .procmailrc lines ##

For more info, please consult the man pages of procmail(1),
procmailrc(5), procmailex(5) etc.

Valuable information is also available at a number of locations such as
Jari Aalto's procmail tips at ftp://cs.uta.fi/pub/ssjaaa/pm-tips.html
or ftp://cs.uta.fi/pub/ssjaaa/pm-tips.txt. You can receive this file
via email by sending an 
email To: jari(_dot_)aalto(_at_)poboxes(_dot_)com 
with  Subject: send help
or    Subject: send pm-tips.txt

There are many good places to get additional info, and Jari shows a
lot of pointers to these various places.

Good luck.

Guido.

On Tue, July 21, 1998 at 07:37 
Colin J. Raven <cjraven(_at_)quik(_dot_)com> wrote :
[snip]
I have mail coming into more than one account, and want to forward a
(limited) number of messages from one account to the other. (The "other"
is the account I access daily, but don't want filled up with rubbish)
So...
      :0:
      *^From: someone(_at_)foo(_dot_)com
      In.crap
sends this message to  a "pre /dev/null" folder, whereas

      :0)
      *^From: someone(_at_)foo(_dot_)com
      Cc: me(_at_)my_other_domain(_dot_)com
sends this message to me (I guess...can procmail "bounce a message BTW?)
How do I do both, i.e. bounce the message to myself at the other account,
then junk the original?
[snip]

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