Re: filtering email via EXIM -- question
On Wed, Jun 06, 2001 at 07:03:14AM -0700, Mark Wagnon wrote:
> On 06/06/01 05:41:58 -0500, will trillich wrote:
> > 2) does the exim filtering mechanism somehow bork the timestamps
> > on mailboxes? when i hopped into mutt a moment ago, i have five
> > boxes with new mail; i checked into one of them, nosed around
> > and switched, and suddenly only two were marked as new.
> > grok-challenged, here. (what else might munge that datum?)
> >
>
> I think this is a mutt thing. When new mail arrives a mailbox, those
> messages are marked as new with the "N" tag. If you switch to another
> box and switch back, then those messages are no longer new, they're
> old, and therefore marked with the "O" tag. This is to distinguish
> them from read messages. Maybe you're experiencing something
> different?
right. on startup, mutt flagged five boxes as having new mail
(via "N" on the index display). i opened one, nosed aruond, and
then did "c" "<tab>" to change to another mbox -- and now there
were only two marked as having new mail. i'd looked at one of
the five, so i expected four to still have new mail.
very strange, that.
> > 3) anybody got some high-power, dual-exhaust, chrome-plated,
> > twin overhead cam examples of exim filters to get us
> > .forwarding newbies off the ground? i've seen the simple ones
> > they've got in /usr/share/doc/exim/filter.html ...
>
> I was going to post mine, but yours is more complicated than mine as
> you're using regexps. Yeah, I just pulled mine together from the
> filtering file in the exim docs. I was looking to make mine a little
> more robust, so I hope some post their .forward file examples here.
me too.
> Aw, what the heck, here's mine:
>
> # Exim filter <<== do not edit or remove this line!
> if error_message then finish endif
>
> if $h_Reply-to: contains "kplug-newbie"
> then save $home/Mail/IN.KPLUG-Newbie
>
> elif $h_Resent-From: contains "debian-user"
> then save $home/Mail/IN.Debian-User
>
> elif $h_Reply-to: contains "kplug-list"
> then save $home/Mail/IN.KPLUG
>
> elif $h_Reply-to: contains "kplug-security"
> then save $home/Mail/IN.KPLUG-Security
>
> elif $h_From: contains "mwagnon@sbusd.k12.ca.us" and
> $h_Subject: contains "Fwd:"
> then save $home/Mail/IN.SBUSD
>
> elif $h_From: contains "Linux news daily mailing list"
> then save $home/Mail/IN.Linux-News
>
> else save $home/Mail/IN.BOX
>
> endif
> # --- of .forward file ---
>
> Not too fancy.
fancy enough to do the job. being a perl wonk, i'm fond of the
regex approach. taxing on the machine, but they pay their taxes
without a grumble, these days, and ask to do more. :)
# Exim filter
if error_message then finish endif
# note all logwrite invocations are atomic, so that
# concurrent filters don't splice their output in the
# logfile; and using the procmail log format i can see my
# stats via "mailstat .forward.log"
logfile $home/.forward.log 0600
# ---------------------------------
# Forward to other account/computer
#
if $h_Subject: contains "[free-thinkers]"
or $h_Subject: matches "Best\s?Op"
or $return_path matches "@.*cmcone.com"
or $return_path matches "kat.*@serensoft.com"
or $return_path matches "katrill@.*aol.com"
or $return_path matches "agf(g|in(ance)?)?\.com"
then
deliver trillich@serensoft.com
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: trillich@serensoft.com"
finish
endif
# ---------------------
# internic domain stuff
#
if $return_path matches "@.*\b(internic|networksolutions)\b"
then
save Mail/internic
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: internic"
finish
endif
# --------------------
# checking system logs
if foranyaddress $h_to:,$h_cc: (${local_part:$thisaddress} is "root")
then
save Mail/root
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: root"
finish
endif
# --------------
# news from cron
if $h_From: contains "Cron Daemon"
then
save Mail/cron
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: cron"
finish
endif
# --------------------
# debian mailing lists
if $h_X-Mailing-List matches "^<debian-(.*)@lists\\\\.debian\\\\.org>" then
#X-Mailing-List: <debian-user@lists.debian.org> archive/latest/151892
then
save MAIL/debian-${lc:$1}
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: debian-${lc:$1}"
finish
endif
# ------------------------
# postgresql mailing lists
if $return_path matches "pgsql-([^-]+)-owner.*@.*postgresql.org"
#Return-path: <pgsql-general-owner+M10489@postgresql.org>
then
save Mail/pg-${lc:$1}
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: pg-${lc:$1}"
finish
endif
# ---------------------
# modperl mailing list
if $return_path matches "modperl.*@apache.org"
#Return-path: <modperl-return-16892-will=serensoft.com@apache.org>
then
save Mail/mperl
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: mperl"
finish
endif
# --------------------
# sourceforge lists
if $return_path matches "(.+-discuss)(-admin)?@lists.sourceforge.net"
#Return-path: <newbiedoc-discuss-admin@lists.sourceforge.net>
then
save Mail/sf-${lc:$1}
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: sf-${lc:$1}"
finish
endif
# -----------------
# hold the gunk
#
if $sender_address_domain ends "whatUseek.com"
or $sender_address_domain ends "whatUseek.com"
or $sender_address_domain ends "websidestory.com"
or $sender_address_domain ends "webreview.com"
or $sender_address_domain ends "webpronews.com"
or $sender_address_domain ends "MotleyFool.com"
or $sender_address_domain ends "SearchHound.com"
or $sender_address_domain ends "about.com"
or $sender_address_domain ends "Mailbits.com"
or $sender_address_domain ends "smtp.quote.com"
or $sender_address_domain ends "accessmicro.com"
or $sender_address_domain ends "itemzone.com"
or $sender_address_domain ends "spedia.net"
or $sender_address_local_part contains "readers.digest"
or $sender_address_local_part contains "TheCounterProfessional"
or $sender_address_local_part contains "intelligentxmailbag"
or $h_to: contains "unknown@unknown.com"
then
save Mail/gunk
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: gunk"
finish
endif
# --------------------
# virtual-domain email (someone@a.virtual.host.serensoft)
#
if foranyaddress $h_to:,$h_cc: ($thisaddress matches "@.*\/(24x7.*4u.com|bucks.*browse.com|on-the-fridge.com|dontUthink.com)")
then
save Mail/domain-${lc:$1}
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: domain-${lc:$1}"
finish
endif
# not-so-incognito personal aliases
if personal
alias trillich@usa.net
alias will@pinncomp.net
alias will@pinncomp.com
then
deliver trillich@serensoft.com
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: trillich@serensoft.com"
finish
endif
# must be junk mail!
save Mail/JUNK-O-RAMA
logwrite "From $return_path $tod_log\n Subject: $h_subject:\n Folder: JUNK-O-RAMA"
finish
--
DEBIAN NEWBIE TIP #15 from Will Trillich <will@serensoft.com>
:
Is there a good place to learn snarky PERL TECHNIQUES? One of
my favorites is http://webtechniques.com, where Randall Schwartz
contributes a monthly sample, explaining line-by-line what his
code does, and why. (Look under "Programming with Perl" in the
archives.)
Also see http://newbieDoc.sourceForge.net/ ...
Reply to: