- 论坛徽章:
- 0
|
2.6. Configuring Exim4 dot forward Filtering
For a detail discussion of Exim's filter system, you should check out Exim's documentation itself. For just the short of it, read on.
In order for Exim to recognize a .forward as having Exim4 filter rules, the first non-whitespace entry must be:
# Exim filter
Character case and anything following it on the same line are ignored.
Next, you'll likely want some rules in your Exim4 filter .forward file. Using a simple if then elif else endif construct you can perform various tests against each incoming email before delivery (or discarding) it to a specified location. You can perform evaluations against any existing entry in an email's header, like so:
# Match any email who's To: header contains "exim"
# and save it to .dir1
if $h_to: contains "exim" then save Maildir/.dir1/
# Match email with a From: header that's
# exactly "not@wanted.com" and save it to .SPAM
elif $h_from: is "not@wanted.com" then save Maildir/.SPAM/
endif
To access the email header of your choice, append $header_, or as abbreviated above, just $h_, to the full name of an email header, following by a colon (:). The keywords is and contains are self explanatory. The save keyword, when followed by a path that ends with a forward slash (/), will deliver the email being evaluated in Maildir format. As such, the trailing slash is crucial. Don't omit it.
In Courier's IMAP hierarchy, directories beneath the root are dot directories. In addition, all subdirectories are denoted by periods, not additional forward slashes. So, lists/Debian/User/ is actually .Lists.Debian.User/ on the filesystem and should be referred to in Exim filters as "save Maildir/.Lists.Debian.User/" for things to be saved the way you expect.
My own personal working Exim filter file looks like this:
# Exim filter
# Save yourselves
if error_message then finish endif
# Let's make use of pipes
# The script accepts input on STDIN and does stuff with the mail
if $h_Subject: contains "uptime report"
then
pipe "$home/bin/uptime.pl"
endif
# Handle mailing lists
if $h_List-Id: contains "leaplist"
then save Maildir/.mailinglists.leap.linux/
elif $h_from: contains "ebay.com"
then save Maildir/.Ebay/
elif $h_Sender: contains "LINUX-L"
then save Maildir/.mailinglists.LUG/
endif
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/10912/showart_199823.html |
|