《NetBSD指南-26.6.高级邮件工具》

NetBSD用户指南中文版、NetBSD pkgsrc指南中文版...

版主: lionux

主题已锁定
头像
leo
帖子: 2465
注册时间: 2010-01-21 3:27

《NetBSD指南-26.6.高级邮件工具》

帖子 leo » 2010-03-08 1:59

When you start using mail, you won't probably have very sophisticated requirements and the already described standard configuration will satisfy all your needs. But for many users the number of daily messages will increase with time and a more rational organization of the mail storage will become necessary, for example subdividing mail in different mail boxes organized by topic. If, for example, you subscribe to a mailing list, you will likely receive many messages every day and you will want to keep them separate from the rest of your mail. You will soon find that you are spending too much time every day repeating the same manual operations to organize your mail boxes.

Why repeat the same operations manually when you can have a program perform them automatically for you? There are numerous tools that you can add to your mail system to increase its flexibility and automatically process your messages. Amongst the most known and used there are:
  • procmail, an advanced mail delivery agent and general purpose mail filter for local mail, which automatically processes incoming mail using user defined rulesets. It integrates smoothly with sendmail/postfix.
  • spamassassin or spamprobe, to help fight spam.
  • metamail, a tool to process attachments.
  • formail, a mail formatter.
In the remaining part of this section a sample configuration for procmail will be presented for a very common case: delivering automatically to a user defined mailbox all the messages coming from a mailing list. The configuration of postfix will be modified in order to call procmail directly (procmail will be the local mailer used by sendmail). and a custom configuration file for procmail will be created.

First, procmail must be installed using the package system (mail/procmail) or pkg_add.

Next, the configuration of postfix must be changed, in order to use procmail as local mailer:

代码: 全选

mailbox_command = /usr/pkg/bin/procmail
The line defines the path of the procmail program (you can see where procmail is installed with the command which procmail).

The last step is the creation of the procmail configuration file, containing the recipes for mail delivery.

Let's say that, for example, you subscribed to a mailing list on roses whose address is “[email protected]” and that every message from the list contains the following line in the header:

代码: 全选

Delivered-To: [email protected]
Assuming you want to automatically sort all mails going over that list into the local mail folder "roses_list", the procmail configuration file (.procmailrc) looks like this:

代码: 全选

PATH=/bin:/usr/bin:/usr/pkg/bin
MAILDIR=$HOME/Mail
LOGFILE=$MAILDIR/from

:0
* ^Delivered-To: [email protected]
roses_list
The previous file contains only one rule, beginning with the line containing “:0”. The following line identifies all messages containing the string “Delivered-To: [email protected]” and the last line says that the selected messages must go to the roses_list mailbox (which you should have created in $MAILDIR). The remaining messages will be delivered to the default mailbox. Note that $MAILDIR is the same directory that you have configured with mutt:

代码: 全选

set folder="~/Mail"
Of course the mailing list is only an example; procmail is a very versatile tool which can be used to filter mail based on many criteria. As usual, refer to the man pages for more details: procmail(1), procmailrc(5), and procmailex(5) (this last one contains many examples of configuration files).

主题已锁定

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客