全部博文(434)
分类: LINUX
2011-06-17 15:00:17
1:安装
#make -f这一句请去掉所有的'\',我这里是为了显示方便,因为其中含有单引号
2:建立邮件存放目录及备份旧文件
3:配置main.cf文件
//main.cf中的注解太多了,不如重新新建来得直观
#vi /etc/postfix/main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.test.com
mydomain = test.com
myorigin = $mydomain
inet_interfaces = all
mydestination =
unknown_local_recipient_reject_code = 550
############################CYRUS-SASL########################
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
#############################SASL-END##############################
#############################Virtual Mailbox Settings################
virtual_mailbox_base=/var/mailbox
virtual_mailbox_maps=mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains=mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf
virtual_alias_domains=
virtual_alias_maps=mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf
virtual_uid_maps=static:1001
virtual_gid_maps=static:1001
virtual_transport=maildrop
maildrop_destination_recipient_limit=1
maildrop_destination_concurrency_limit=1
#################################Mailbox END###########################
要注意的地方是 virtual_uid_maps及virtual_gid_maps的值,它是vmail用户uid和postfix组的gid,与前面的文件 /usr/local/authlib/etc/authlib/authmysqlrc 的"MYSQL_UID_FIELD""MYSQL_GID_FIELD"一定要保持一致
#################################Quota Settings########################
message_size_limit=52428800
mailbox_size_limit = 209715200
virtual_mailbox_limit=207915200
virtual_create_maildirsize=yes
virtual_mailbox_extended=yes
virtual_mailbox_limit_maps=mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override=yes
virtual_maildir_limit_message=User's maildir has overdrawn his diskspace quota,try again later.
virtual_overquota_bounce=yes
################################Quota END############################
################################Amavis Start##########################
content_filter=amavisfeed:[127.0.0.1]:10024
receive_override_options = no_address_mappings
max_use=10
################################Amavis END###########################
debug_peer_level = 2
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
xxgdb $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = /var/www/extsuite/extmail/html/
manpage_directory = /usr/local/man
sample_directory = /etc/postfix
mynetworks = 192.168.7.0/24, 192.168.3.0/24, 127.0.0.0/8
relay_domains = $mydestination
alias_maps = hash:/etc/aliases
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
readme_directory = no
4:配置master.cf文件
//注意此文件中的有空格的地方
#vi /etc/postfix/master.cf
smtp inet n - n - - smtpd
pickup fifo n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr fifo n - n 300 1 qmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
-o smtp_fallback_relay=
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/local/sbin/maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}
#注意:flags前有两个空格
cyrus unix - n n - - pipe
user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
old-cyrus unix - n n - - pipe
flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=bsmtp argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
amavisfeed unix - - n - 3 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
-o max_use=20
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=
-o smtpd_delay_reject=no
-o smtpd_client_restrictions=permit_mynetworks,reject
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_data_restrictions=reject_unauth_pipelining
-o smtpd_end_of_data_restrictions=
-o smtpd_restriction_classes=
-o mynetworks=127.0.0.0/8
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o smtpd_client_connection_count_limit=0
-o smtpd_client_connection_rate_limit=0
-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
-o local_header_rewrite_clients=
#注意:-o前有两个空格
5:添加为支持虚拟域和虚拟用户所用到的配置文件
//直接在extman中复制过去就可以了
6、注意:
*在postfix的配置文件中,参数行和注释行是不能处在同一行中的;
*任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;
*每修改参数及其值后执行 postfix reload 即可令其生效;但若修改了inet_interfaces,则需重新启动postfix;
*如果一个参数的值有多个,可以将它们放在不同的行中,只需要在其后的每个行前多置一个空格即可;postfix会把第一个字符为空格或tab的文本行视为上一行的延续;
#
7、启动postfix
# /usr/sbin/postfix start
Postfix的postfix工具提供了一个check命令,可帮助你检查当前的 配置是否有问题、文件与目录的拥有权是否正确,甚至帮你创建任何遗失的目录。运行方式如下:
#postfix check
配置文件与查询表: /etc/postfix
Postfix的各个服务器程序:/usr/libexec/postfix/
队列文件: /var/spool/postfix/
Postfix工具程序:/usr/sbin/
查看日志:
# egrep '(reject|warnging|error|fatal|panic):' /var/log/maillog
8、查看系统日志是否有报错
#tail -f /var/log/messages
如若出现以下问题:
(1)warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
解决办法:系统默认使用了nis,你可以设置一下:
修改/etc/postfix/main.cf
alias_maps = hash:/etc/aliases 就可以禁止掉默认的nis
原因如下:postconf -d │grep nis
alias_maps = hash:/etc/aliases, nis:mail.aliases
(2)Jun 16 17:44:47 mail postfix/trivial-rewrite[15117]: warning: do not list domain harrytest.com in BOTH mydestination and virtual_mailbox_domains
解决:
mydestination会自动根据机器名生成,因此如果不希望使用它的话,应将其设为空:postconf -e mydestination=
#从日志中统计退回、拒收、超时失败的邮件