#*** Special comments for SfinxUpdate:
#SfinxFileName: procmailrc-spamassassin
#UserFileName: .procmailrc
# %SFINX_RELATED%    forward
# %SFINX_NEEDS_EDIT% Default settings is to put spam in a folder named "junk". If you want procmail/spamassassin to put spam in another folder, edit .procmailrc
. 
#*** End of special comments for SfinxUpdate

#
# SET VARIABLES

##############################################################################
# Internal Variables

SHELL=/bin/sh               #Shell used to run procmail. Be sure this points to
                            #your system's copy of sh.  DO NOT substitute a
                            #different shell unless you really know UNIX

LINEBUF=4096                #Needed to keep Procmail from choking on long
                            #"recipes", or instructions on what to do with
                            #particular kinds of email.

PATH=/usr/bin:/bin:/software/local/bin
                            #Path for your programs -- this is probably best
                            #left alone.

VERBOSE=off                 #Change this to "on" when you try a new recipe
                            #so that Procmail will log literally every step
                            #it takes.  DO NOT LEAVE IT ON, though, because
                            #it creates huge logfiles.


##############################################################################
# Default Program & file locations

FORMAIL=/usr/bin/formail                # useful for autoreply recipes.
SENDMAIL=/usr/sbin/sendmail		# useful for autoreply recipes.

MAILDIR=${HOME}/Maildir/.               # You'd better make sure this directory exists!

DEFAULT=/var/spool/mail/${LOGNAME}/	#default incoming mailbox = Maildir !

# Folder to save spam to:
JUNKFOLDER=${MAILDIR}junk/

# There is no automatic deletion in procmail, but you can use the next best 
# thing: save to /dev/null
#JUNKFOLDER=/dev/null

# JUNKFOLDER=${DEFAULT} takes care of the case when you want mail in your
# default mailbox (eg to filter in thunderbird) 
#JUNKFOLDER=${DEFAULT}

##############################################################################
#Spamassassin begin

# All mail is already filtered by MailScanner and SpamAssassin
# but in case you want a customized SpamAssassin, run it again here:
# beware that this puts quite some load on the mailserver, so consult
# with system management before enabling this option
#:0fw: spamassassin.lock
#| /usr/bin/spamc

## Mail tagged as spam by SpamAssassin
:0:
* ^X-Spam-Flag: YES
:0:
* ^Subject: \{Spam\?\}
$JUNKFOLDER

# Comment the preceeding lines if you wish procmail to leave all mail
# in the mailbox (if you use a pop or imap client)
# On the other hand: in that case you can bypass this .procmailrc completely.

#############################################################################
# e-mail forwarding:
# Many mailservers are sending out error messages or notices if mail is 
# recognized as spam. I don't know if that makes any sense, and our server
# does not do that. But anyway, if you have your e-mail forwarded to a place
# that does this, the reply ends up with us (postmaster@strw) and not with the
# spammer. So be nice to your friendly sysadmins, and don't put a unconditional
# forwarding in .forward, but in stead, use procmail to filter out the spam,
# and only forward the mail if it passes the test. So if you want to forward
# your mail, use one of the following recipes (and make sure they stay at the 
# END of this file!).

# If you want a copy of your mail forwarded to another address, use this:
#:0 c
#  ! your_address@remoteserver.edu

# If you want your mail forwarded to another address, without a local copy
# (especially useful if you no longer work here) use this:
#:0
#  ! your_address@remoteserver.edu

#############################################################################
# Similar to the note about mail forwarding (see above), use of the 'vacation'
# program is not always a good idea. It causes spam bounces to the local
# postmaster (who probably has better things to do than reading spam addressed
# to you) and in the worst case, it confirms the validity of your e-mail 
# address to the spammer, which makes your address so much more valuable to
# him. So if you don't want to be burried in spam when you come back from
# your trip, don't use 'vacation', but use this vacation-like setup
# (from procmailex man page, modified for local settings)
#
# Additional note: as of Fedora Core 1(?), the vacation program is no longer
# distributed with the mail server setup, probably because of these same 
# reasons. All the more reason to use an alternative like this.

# New, the E.R. Deul way. SMS "vacation on" to 8444 or something like that :
VAC_MESSAGE=$HOME/.vacation.msg
VAC_CACHE=$HOME/.vacation.cache
VAC_LOCK=$HOME/.vacation.lock
NL="
"

# test if message is to and from the same address and if suject is
# "vacation on" or "vacation off"
:0
# adressed to a system user
*$ ^TO_$LOGNAME@
# and is from that same user
*$ ^From:.*$LOGNAME@
# has subject containing only "vacation (on|off)"
*  ^Subject: *vacation *\/o(ff|n) *$
# clean out extra space
*  MATCH ?? ()\/o(ff|n)
{
    ACTION=$MATCH
    #LOG="ACTION: $ACTION, USER: $LOGNAME, HOME: $HOME $NL"

    :0c
    * ACTION ?? off
    # remove vacation message and cache
    | rm $VAC_MESSAGE $VAC_CACHE
    :0Ebc
    # create vacation message from body
    | cat > $VAC_MESSAGE
    # FIXME: extra newline in output; how to deal with attachements?

    # As confirmation that vacation works the user will receive his own
    # auto-reply from the next recipe
}

:0
# is there a vacation message for that user?
*$? "test -e $VAC_MESSAGE"
{

    # from procmailex
    :0 Whc: $VAC_LOCK
    # Perform a quick check to see if the mail was addressed (to|cc) us
    *$ ^TO_$\LOGNAME@
    # Don't reply to daemons and mailinglists
    *  !^FROM_DAEMON
    # Mail loops are evil
    *$ !^X-Loop: $LOGNAME@$HOST
    | formail -rD 8192 $VAC_CACHE

    # if the name was not in the cache
    :0 ehc        
    | (formail -rI"Precedence: junk" -A"X-Loop: $LOGNAME@$HOST" ; \
        cat $VAC_MESSAGE ) | $SENDMAIL -oi -t

}

# "vacation" end
##############################################################################

##############################################################################
# if you want your new mail to be delivered to a folder in your home, e.g.
# to make it easier to read the mail with mutt or pine, activate this, and
# configure your mail client to use the file you specify here as your inbox
#    mutt: .muttrc: set spoolfile=~/mail/incoming
#    pine: .pinerc: inboxpath=~/mail/incoming
#    elm: setenv MAIL ~/mail/incoming (in .cshrc or .settings)

#:0:
#incoming

# .procmailrc end
##############################################################################