wiflish
Loving Life! Loving Coding!
posts - 98,comments - 98,trackbacks - 0

参考文档:
http://blog.5ilinux.com/archives/2006/05/postfix_cyrussa.html
http://www.extmail.org/forum/archive/2/0510/563.html

wget ftp://postfix.cn99.com/postfix/official/postfix-2.2.10.tar.gz

tar zvxf postfix-2.2.10.tar.gz

下载VDA补丁,使postfix支持磁盘限额
wget http://web.onda.com.br/nadal/postfix/VDA/postfix-2.2.10-vda.patch.gz

gzip -d  postfix-2.2.10-vda.patch.gz

chkconfig --level 2345 sendmail off

安装postfix之前添加相关的用户&用户组
groupadd postfix -g 1000
groupadd postdrop
useradd postfix -u 1000 -g postfix -G postdrop
groupadd vmail -g 1002
useradd vmail -u 1002 -g 1002
mkdir /opt/virtual
chown vmail:vmail /opt/virtual
chmod -R 771 /opt/virtual

cd postfix-2.2.10
打补丁
patch -p1 < ../postfix-2.2.10-vda.patch

make tidy

make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/ -DUSE_SASL_AUTH -I/usr/local/include/sasl' \
'AUXLIBS=-L/usr/local/mysql/lib/ -lmysqlclient -lm -lz -L/usr/local/lib -lsasl2'

make
make install

mv /etc/aliases /etc/aliases.old
ln -s /etc/postfix/aliases /etc/aliases
echo 'root: admin@example.com'>>/etc/postfix/aliases
/usr/bin/newaliases

touch /etc/postfix/mysql/virtual_alias_maps.cf
touch /etc/postfix/mysql/virtual_domains_maps.cf
touch /etc/postfix/mysql/virtual_mailbox_maps.cf
touch /etc/postfix/mysql/virtual_limit_maps.cf

cd /etc/postfix
postconf -n > main2.cf
mv main.cf main.cf.old
mv main2.cf main.cf

vi /etc/postfix/main.cf
myhostname = mail.example.com         # mail.example.com是安装Postfix软件的主机名
mydomain = example.com                # example.com是安装Postfix软件的主机名中的域名部分
myorigin = $mydomain
mydestination =
alias_maps = hash:/etc/aliases
home_mailbox = Maildir/               # 使用Maildir作为邮件的存储格式


#=====================MySQL=====================
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf
virtual_mailbox_base = /opt/virtual
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf
virtual_mailbox_limit = 102400000
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf
virtual_minimum_uid = 1002
virtual_uid_maps = static:1002
virtual_gid_maps = static:1002
virtual_transport = virtual
#"virtual_gid_maps"和"virtual_uid_maps"是postfix用户的gid和uid, "virtual_minimum_uid"应当≤"virtual_uid_maps",

"virtual_mailbox_limit"是每个邮箱的大小。

#=====================Quota=====================
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/virtual_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes
#virtual_trash_count=yes
#virtual_trash_name=.Trash

#====================SASL======================
smtpd_recipient_restrictions =
 permit_mynetworks,
 permit_sasl_authenticated,
 reject_non_fqdn_hostname,
 reject_non_fqdn_sender,
 reject_non_fqdn_recipient,
 reject_unauth_destination,
 reject_unauth_pipelining,
 reject_invalid_hostname
 #reject_rbl_client opm.blitzed.org,
 #reject_rbl_client list.dsbl.org,
 #reject_rbl_client bl.spamcop.net,
 #reject_rbl_client sbl-xbl.spamhaus.org
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes

#=============================================
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/man
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
unknown_local_recipient_reject_code = 550


编辑cf配置文件

vi /etc/postfix/mysql_virtual_alias_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'

=================================

vi /etc/postfix/mysql_virtual_domains_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = domain
select_field = description
where_field = domain
additional_conditions = AND active = '1'

=================================

vi /etc/postfix/mysql_virtual_mailbox_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
additional_conditions = AND active = '1'

=================================

vi /etc/postfix/mysql_virtual_limit_maps.cf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
additional_conditions = AND active = '1'


启动和停止postfix服务
/usr/sbin/postfix start
/usr/sbin/postfix stop

设置Postfix开机自动运行,在/etc/rc.local中增加“/usr/sbin/postfix start&”。
注:①系统已经打开了Postfix的TLS支持,如果你需要这项功能可以参考Postfix发行包中的TLS_README文档进行配置。
    ②你可以使用一个叫pflogsumm.pl的perl脚本对postfix的日志进行分析,详细的情况见:http://jimsun.linxnet.com/postfix_contrib.html

posted on 2006-12-01 14:17 想飞的鱼 阅读(515) 评论(0)  编辑  收藏 所属分类: linux

只有注册用户登录后才能发表评论。


网站导航: