简单了解procmail

一,什么是procmail

  procmail 是一个强大得惊人的过滤进入邮件的应用程序。 它允许用户定义 “规则”, 并用这些规则来匹配进入的邮件, 进而执行某些特定的功能, 或将这些邮件转发到

其他信箱和/或邮件地址。

[@more@]

二,Procmail, A Mail Delivery Agent (邮件分发代理)

Different uses include:
1,sorting incoming email into different folders or files
2, preprocessing email
3, starting an event or program when email is received
4, automatically forwarding email to others

启用procmail
1,sendmail 默认已经启用。
2,postfix: 修改 /etc/postfix/main.cf

mailbox_command = /usr/bin/procmail

3, 查看是否安装procmail
[root@station10 ~]# rpm -aq | grep procmail
procmail-3.22-17.1
[root@station10 ~]#

三,procmail and Access controls

initial controls
1,SELinux policy restricts mail utilies to certain directories
2,procmail runs as nobody
3,procmail is owned by the mail group
4,/var/spool/mail is writable only by root and the mail group

必须的操作:改变procmail的权限,配置sgid
chmod g+s $(which procmail)


配置:
postfix修改/etc/postfix/mail.cf文件:

#mailbox_command = /some/where/procmail
#mailbox_command = /some/where/procmail -a "$EXTENSION"
mailbox_command = /usr/bin/procmail
"/etc/postfix/main.cf" 672L, 26912C written

[root@station10 ~]# service postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
[root@station10 ~]# chmod g+s $(which procmail)
[root@station10 ~]# ls -al $(which procmail)
-rwxr-sr-x 1 root mail 92452 Jul 13 2006 /usr/bin/procmail
[root@station10 ~]#


四,intro to procmail configuration

Configuration files are processed in order if they exist
1,/etc/procmailrc
2,~/.procmailrc 用户自定义的操作

Elements within a configuration file
1,Directives: VERBOSE=yes
2,Variables: LOGFILE=/var/spool/mail/procmail.log
3,Recipes
Begin with a ":0" line and flags
Zero or more match lines using regular expressions
one or more action lines

五,Sample Procmail Recipe

:0*
^From.*joshua* ---名字中包含这个名字
^Subject:.*ADSL ---主题中包含这些字符的
{
:0 c
! Jim@somedomain.org ---转发给这个人

:0:
ADSL
}

man pages:procmailex,procmailrc,procmail

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-1012225/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/312079/viewspace-1012225/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值