# procmailrc

## lasa

After quite som fiddling I got a nice procmailrc up and running, which so far hasn't produced any errors. Note that a few things had to be done to get rid of some annoying warnings and errors.

```

# Turn this on for debugging

VERBOSE=off

# Do a chmod g+w /var/spool/mail to get rid of locking errors

DEFAULT=/var/spool/mail/$LOGNAME

# Use a common logfile

LOGFILE=/var/log/mail/procmail.log

# Set up the directories

MAILDIR=$HOME/mail

SPAMBOX=$MAILDIR/trash

# Create a lock so that only one concurrent user mail is checked

BOXLOCK=$MAILDIR/$LOGNAME.lock

# To avoid "insecurity" warnings from perl

DROPPRIVS=yes

# SpamAssassin (on mail less than 512kB) including the razor

:0fw: $BOXLOCK

* < 512000

| spamassassin -a

:0:

* ^X-Spam-Status: Yes

$SPAMBOX

```

I'm just posting this to help others who'll stumble upon the same problems as I did.

Lars

----------

## rizzo

I'll assume that I need to emerge Mail-SpamAssassin and razor for this as well as procmail.  Is this file the /etc/procmailrc file or is it intended for the user's .procmailrc file.

Do I need to configure postfix (I use fetchmail + postfix + pine with mbox) to run this?

----------

## rizzo

OK the more I try I believe this is supposed to be a system-wide /etc/procmailrc file, since it writes to /var.

Also for other dopes like me, you need to set mailbox_command in your /etc/postfix/main.cf to /usr/bin/procmail.

----------

## lasa

Sorry for not being of any help, but you seem to have figured it out anyway. I haven't been visiting the forum lately. There is however one problem with the setup that I haven't been able to solve. The following will show up in procmail.log every now and then:

 *Quote:*   

> 
> 
> From CorineH@line-biz.com  Thu Jun 26 11:22:19 2003
> 
>  Subject: fresh wet f_cking huge
> ...

 

Having examined the logs this always seem to happen when the subject line starts with an ISO-specification. Unfortunately these mails fall through to my regular mailbox even though they are detected as spam. I tried removing the trailing : from the last recipe but I still get the same error.

Any help would be greatly appreciated,

Lars

----------

## lasa

I added sanitizer with support for clamav. This is what my new procmailrc looks like:

```

# Turn this on for debugging

VERBOSE=off

# Do a chmod g+w /var/spool/mail to get rid of locking errors

DEFAULT=/var/spool/mail/$LOGNAME

# Use a common logfile

LOGFILE=/var/log/mail/procmail.log

# Set up the directories

MAILDIR=$HOME/mail

SPAMBOX=$MAILDIR/trash

# Create a lock so that only one concurrent user mail is checked

BOXLOCK=$MAILDIR/$LOGNAME.lock

# To avoid "insecurity" warnings from perl

DROPPRIVS=yes

# SpamAssassin (on mail less than 512kB) including the razor

:0fw: $BOXLOCK

* < 512000

| spamassassin -a

:0: $BOXLOCK

* ^X-Spam-Status: Yes

$SPAMBOX

# Anomy Sanitizer

ANOMY=/opt/anomy

:0fw: $BOXLOCK

| $ANOMY/bin/sanitizer.pl /etc/anomy.conf

```

And the contents of the anomy sanitizer configuration file is:

```

# Active features.

#

feat_boundaries     = 0

feat_files          = 1

feat_forwards       = 1

feat_html           = 1

feat_lengths        = 1

feat_log_inline     = 1

feat_log_stderr     = 0

feat_scripts        = 1

feat_trust_pgp      = 0

feat_uuencoded      = 1

feat_verbose        = 1

file_list_rules     = 4

#

# Note:  This directory must exist and be writable by

# the user running the sanitizer.

#

file_name_tpl       = /var/spool/quarantine/att-$F-$T.$$

# Files we absolutely don't want (mostly executables).

#

file_list_1_scanner = 0

file_list_1_policy  = save

file_list_1         = (?i)(winmail\.dat

file_list_1        += |\.(exe|vb[es]|c(om|hm)|bat|pif|s(ys|cr))

file_list_1        += (\.g?z|\.bz\d?)*)$

# Pure data, don't mangle this stuff (much).

#

file_list_2_scanner = 0

file_list_2_policy  = accept

file_list_2         = (?i)\.(gif|jpe?g|pn[mg]|x[pb]m|dvi|e?ps|p(df|cx)|bmp

file_list_2        += |mp[32]|wav|au|ram?

file_list_2        += |avi|mov|mpe?g

file_list_2        += |t(xt|ex)|csv|l(og|yx)|sql|jtmpl

file_list_2        += |[ch](pp|\+\+)?|s|inc|asm|pa(tch|s)|java|php\d?

file_list_2        += |[ja]sp

file_list_2        += |can|pos|ux|reg|kbf|xal|\d+)(\.g?z|\.bz\d?)*$

file_list_3_scanner = 0

file_list_3_policy  = accept

file_list_3         = ^[^\.]+$

# Archives and scriptable stuff - virus scan these.

# NOTE:  There must be THREE groups of exit codes and FOUR policies,

#      - the first three match the code groups, the fourth is default.

#

file_list_4_scanner = 0:40:1:/usr/bin/clamscan --quiet %FILENAME

file_list_4_policy  = accept:save:drop:accept

file_list_4         = (?i)\.(xls|d(at|oc)|p(pt|l)|rtf|[sp]?html?

file_list_4        += |class|upd|wp\d?|m?db

file_list_4        += |z(ip|oo)|ar[cj]|lha|[tr]ar|rpm|deb|slp|tgz

file_list_4        += )(\.g?z|\.bz\d?)*$

# Default policy: accept, but mangle file name.

#

file_default_policy = defang

```

-lasa-

----------

## lasa

Having investigated the implicit lockfile error further, it doesn't seem to be related to any particular kind of messages. However, as you can see in my new procmailrc I do name an explicit lockfile for the trash recipe. What I don't understand is why I am still getting:

 *Quote:*   

> 
> 
> procmail: Couldn't determine implicit lockfile from "trash"
> 
> trash: line 1: From: command not found
> ...

 

when apparently most messages are delivered to trash as they should?

-lasa-

----------

