Chinaunix首页 | 论坛 | 博客
  • 博客访问: 508335
  • 博文数量: 105
  • 博客积分: 4174
  • 博客等级: 上校
  • 技术积分: 1395
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-07 11:35
文章分类

全部博文(105)

文章存档

2013年(3)

2012年(16)

2011年(71)

2010年(3)

2009年(6)

2008年(6)

分类: LINUX

2008-04-22 10:08:39

1. 安装alterMIME
  tar zxvf altermime-0.3.8.tar.gz
  cd altermin3-0.3.8
  make
  make install
  altermine将被编译安装到/usr/local/bin/

2. 使用必备条件:一个运行且配置正常的邮件服务器

3. 配置AlterMIME
3.1 为altermine创建一个系统帐号,如下:
  useradd -r -c "Postfix Filters" -d /var/spool/filter filter
  mkdir /var/spool/filter
  chown filter:filter /var/spool/filter
  chmod 750 /var/spool/filter

3.2 创建一个脚本用来运行altermine,vi /etc/postfix/disclaimer,如下:

#!/bin/sh
# Localize these.
INSPECT_DIR=/var/spool/filter
SENDMAIL=/usr/sbin/sendmail.postfix

####### Changed From Original Script #######
DISCLAIMER_ADDRESSES=/etc/postfix/disclaimer_addresses
####### Changed From Original Script END #######

# Exit codes from
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit
$EX_TEMPFAIL; }

cat >in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

####### Changed From Original Script #######
# obtain From address
from_address=`grep -m 1 "From:" in.$$ | cut -d "<" -f 2 | cut -d ">" -f 1`

if [ `grep -wi ^${from_address}$ ${DISCLAIMER_ADDRESSES}` ]; then
  /usr/bin/altermime --input=in.$$ \
  --disclaimer=/etc/postfix/disclaimer.txt \
  --disclaimer-html=/etc/postfix/disclaimer.txt \
  --xheader="X-Copyrighted-Material: Please visit " || \
  { echo Message content rejected; exit $EX_UNAVAILABLE; }
fi
####### Changed From Original Script END #######

$SENDMAIL "$@" exit $?

3.3 修改组及权限,是的可以运行此脚本
  chgrp filter /etc/postfix/disclaimer
  chmod 750 /etc/postfix/disclaimer

3.4 创建一个文件包含所有那些需要使用altermine来处理的帐号列表
  vi /etc/postfix/disclaimer_addresses
  内容如下:
  olli@example.com
  falko@example.com
  till@example.com
 

3.5 创建一个文件,包含需要在邮件中添加的内容
  vi /etc/postfix/disclaimer.txt
  举例如下:
  -------------------
  EXAMPLE Company
  Examplestreet 1
  Examplecity
 

4. 配置Postfix的相关文件
  vi /etc/postfix/master.cf

Add the line "-o content_filter=dfilt:" (without the quotes) straight below the line for smtp. Keep in mind, that the new line has to begin with at least one whitespace.

The corresponding part should look like this:

smtp inet n - n - - smtpd
  -o content_filter=dfilt:
Add the following lines at the end of the file. Keep in mind, that the line with the flags (flags=...) has to begin with at least one whitespace.

# altermime

dfilt unix - n n - - pipe
  flags=Rq user=filter argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}
Afterwards restart Postfix.

5. 重启postfix服务
  /etc/init.d/postfix restart




阅读(1629) | 评论(0) | 转发(0) |
0

上一篇:DB2 v9 安装步骤

下一篇:Awk学习笔记

给主人留下些什么吧!~~