After much experimentation, I got procmail working. I suppose there are other ways to do it, but this works. I had to abandon the desire to forward
Procmail is a mail processing utility which can filter
- Build a
catch-all - Build a
command-line - Build
real-name human users. These accounts are private and the names should never be published. The users must configure- Prepare your {.procmailrc} recipe file saving it in the {/} directory on the server. Be sure to include {MAILDIR=/var/spool/mail} in that recipe file. Do not use "forward" action lines (those that begin with {!}) but instead use "save to a folder" action lines, naming the appropriate
real-name - That's it -- everything else is standard procmail.
- Here's an example .procmailrc:
When confident with your procmail recipe design, change all the spam etc. names to {/dev/null}. Also, periodically review and delete the ..._mail files.
# Save as .procmailrc in UNIX (LF only) format. 10:13 PM 12/25/2002
JANE=maryjanedoe
JOHN=johnedwarddoe
QUOTE='"'
VERBOSE=no
SHELL=/usr/bin/sh
SENDMAIL="/usr/sbin/sendmail"
MAILDIR=/var/spool/mail
DEFAULT=/var/spool/mail/prc.out
LOGFILE=/var/spool/mail/Procmail_log
LOGABSTRACT=all
:0
* ^From: +\/.*
{ FROM = $MATCH }
:0
* ^TO_ *\/.*
{ INTO = $MATCH }
:0
* ^TO_I-SALES@LIST.ADVENTIVE.COM
{ LOG="
Forward list-driven email. $MATCH
To:$INTO From: $FROM
"
:0:
$JANE
}
:0
* ^Subject:.*\/(delivery failed|returned mail|undelivered|undeliverable|virus found in sent message|virus detected|virus alert)
{ LOG="
Purge returned mail. $MATCH
To:$INTO From: $FROM
"
:0:
returned_mail
}
:0
* ^Subject:.*\/(award.*submission|site.*of.*the.*nite.*url.*submission)
{ LOG="
Purge award submission in subject. $MATCH
To:$INTO From: $FROM
"
:0:
awards_mail
}
:0
* ^Subject:.*(investigate.*your.*friends.*enemies.*lovers|prevent.*job.*monotony|find.*love.*today|humorsitesnewsletter|a.*very.*funny.*game|mortgage.*rates.*are.*down|credit.*card.*debt|crazy.*vegas.*casino|daily.*joke.*mail|adv.*website.*promotion|human.*growth.*hormone|get.*the.*credit.*you.*deserve|bulk.*email.*web.*hosting|thinking.*of.*refinancing)
{ LOG="
Purge spam. $MATCH
To:$INTO From: $FROM
"
:0:
spam_mail
}
:0
* ^Content-Type: multipart/
{
:0 B
* ^Content-Type:.*(attachment|application|audio).*($)*.*\/name=.*(bat|exe|pif|scr)['$QUOTE]*
{ LOG="
Purge mail with executable attached. $MATCH
To:$INTO From: $FROM
"
:0
/dev/null
}
}
:0 B
* ^.*content-type: text/html.*
{
:0 B
* ^\/.*(onload=")*open()\(.*
{ LOG="
Purge mail with window.open in script. $MATCH
To:$INTO From: $FROM
"
:0:
winopen_mail
}
:0 B
* ^\/.*<script.*src=
{ LOG="
Purge mail with script source. $MATCH
To:$INTO From: $FROM
"
:0:
scriptsrc_mail
}
:0 B
* ^\/.*(hansi-font-family|3DSimSun)
{ LOG="
Purge mail with crazy fonts. $MATCH
To:$INTO From: $FROM
"
:0:
fonts_mail
}
}
:0 B
* ^.*\/(this.*promotion.*was.*brought.*to.*you.*by.*opt.*in.*inc|this.*email.*was.*sent.*to.*you.*via.*saf-e.*mail.*systems|this.*submission.*was.*made.*using.*the.*webmaster.*multitool|this.*submission.*was.*made.*using.*the.*swiss.*army.*app|your.*email.*address.*was.*obtained.*from.*an.*opt-in.*list|if.*you.*would.*no.*longer.*like.*to.*receive.*our.*offers|you.*received.*this.*email.*because.*you.*signed.*up.*at.*one.*of.*our.*media.*partner.*websites|the.*new.*biz.*and.*info.*domain.*extensions.*are.*now.*conveniently.*available.*at)
{ LOG="
Purge spam. $MATCH
To:$INTO From: $FROM
"
:0:
spam_mail
}
:0
* ^TO_(ads|contact|feedback|web)@([-a-z0-9_]+\.)*(acme|acmecompany|acmestore)+.com
{ LOG="
Forward email.
To:$INTO From: $FROM
"
:0:
$JANE
}
:0
* ^TO_.*@([-a-z0-9_]+\.)*(acme|acmecompany|acmestore)\.com
{ LOG="
Forward email.
To:$INTO From: $FROM
"
:0:
$JOHN
}
:0
{ LOG="
Purge unknown mail.
To:$INTO From: $FROM
"
:0:
unknown_mail
}
Copyright © 2002 John G. Derrickson - 2002DEC27