编译安装
xxxx
添加postfix用户 [1]BSD
[root@linux src]# groupadd -g 1000 postfix [root@linux src]# groupadd -g 1001 postdrop [root@linux src]# useradd postfix -u 1000 -g 1000 -d /dev/null -s /bin/false |
给Postfix邮箱空间配额打补丁
[root@linux src]# patch -p0 < postfix-2.0.19.patch patching file postfix-2.0.19/src/global/mail_params.h patching file postfix-2.0.19/src/util/file_limit.c patching file postfix-2.0.19/src/virtual/mailbox.c patching file postfix-2.0.19/src/virtual/maildir.c patching file postfix-2.0.19/src/virtual/virtual.c patching file postfix-2.0.19/src/virtual/virtual.h |
编译安装
[root@linux src]# cd postfix-2.0.19 [root@linux postfix-2.0.19]# make tidy [root@linux postfix-2.0.19]# make clean [root@linux postfix-2.0.19]# make -f Makefile.init makefiles 'CCARGS=-DUSE_SASL_AUTH -DHAS_MYSQL -I/usr/include/mysql -I/usr/include/sasl' \ 'AUXLIBS=-L/usr/lib/mysql -L/usr/lib/sasl2 -lmysqlclient -lsasl2 -lz -lm' [root@linux postfix-2.0.19]# make [root@linux postfix-2.0.19]# make install |
make tidy(如果你之前编译过Postfix使用此命令)
make upgrade(升级老版本使用此命令)
make -f Makefile.init makefiles 'CCARGS=-DHAS_LDAP -I<ldap的include目录> -DUSE_SASL_AUTH -I/usr/local/include/sasl' 'AUXLIBS=-L<ldap的lib目录> -llber -lldap -L/usr/local/lib -lsasl2'
!!!!!!这里切记要指定正确的SASL2的INCLUDE和LIB位置。由于现在很多linux发行版上都已经带有了sasl,如果不指定的话,很可能会使用了不同版本的头文件和库,在这种情况下,每次连接SMTP时,smtpd就会发生致命错误“Fatal: SASL per-connection server init...”而崩溃。
配置安装目录
安装程序会提问一些问题,可以直接按回车采用默认值。
Please specify the prefix for installed file names. Specify this ONLY if you are building ready-to-install packages for distribution to other machines. install_root: [/] Please specify a directory for scratch files while installing Postfix. You must have write permission in this directory. tempdir: [/root/src/postfix-2.0.19] Please specify the final destination directory for installed Postfix configuration files. config_directory: [/etc/postfix] Please specify the final destination directory for installed Postfix daemon programs. This directory should not be in the command search path of any users. daemon_directory: [/usr/libexec/postfix] Please specify the final destination directory for installed Postfix administrative commands. This directory should be in the command search path of adminstrative users. command_directory: [/usr/sbin] Please specify the final destination directory for Postfix queues. queue_directory: [/var/spool/postfix] Please specify the final destination pathname for the installed Postfix sendmail command. This is the Sendmail-compatible mail posting interface. sendmail_path: [/usr/sbin/sendmail] Please specify the final destination pathname for the installed Postfix newaliases command. This is the Sendmail-compatible command to build alias databases for the Postfix local delivery agent. newaliases_path: [/usr/bin/newaliases] Please specify the final destination pathname for the installed Postfix mailq command. This is the Sendmail-compatible mail queue listing command. mailq_path: [/usr/bin/mailq] Please specify the owner of the Postfix queue. Specify an account with numerical user ID and group ID values that are not used by any other accounts on the system. mail_owner: [postfix] Please specify the group for mail submission and for queue management commands. Specify a group name with a numerical group ID that is not shared with other accounts, not even with the Postfix mail_owner account. You can no longer specify "no" here. setgid_group: [postdrop] Please specify the destination directory for the Postfix on-line manual pages. You can no longer specify "no" here. manpage_directory: [/usr/local/man] Please specify the destination directory for the Postfix sample configuration files. sample_directory: [/etc/postfix] Please specify the destination directory for the Postfix README files. Specify "no" if you do not want to install these files. readme_directory: [no] |
main.cf
[root@linux postfix]# vi main.cf #======= BASE ============== #mail_spool_directory = /var/mail/ myhostname = mail.example.net mydomain = example.net home_mailbox=Maildir/ mydestination = $myhostname, $mydomain, $transport_maps local_recipient_maps = #mailbox_command= /usr/lib/courier-imap/bin/deliverquota -w 90 ~/Maildir #mailbox_command = /usr/local/maildrop/bin/maildrop #local_destination_concurrency_limit = 1 #======= MYSQL ============= transport_maps = mysql:/etc/postfix/mysql_transport.cf virtual_mailbox_base = /var/mail virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual.cf virtual_maps = mysql:/etc/postfix/mysql_aliases.cf #virtual_uid_maps = mysql:/etc/postfix/uids.cf #virtual_gid_maps = mysql:/etc/postfix/gids.cf virtual_uid_maps = static:1000 virtual_gid_maps = static:1000 #======= Quota ============ #50MB virtual_mailbox_limit = 500000000 #5MB message_size_limit = 50000000 virtual_mailbox_limit_inbox = no virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_quota.cf virtual_mailbox_limit_override = yes virtual_maildir_extended = yes virtual_create_maildirsize = yes #====== SASL ================ smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_sasl_authenticated permit_auth_destination reject #smtpd_sasl_local_domain = $mydomain smtpd_client_restrictions = permit_sasl_authenticated |
/etc/postfix/mysql_transport.cf
[root@linuxas3 postfix]# cat /etc/postfix/mysql_transport.cf #mysql_transport.cf hosts = localhost user = postfix password = 6AJx9Nqv9x8hg dbname = postfix table = postfix_transport select_field = transport where_field = domain [root@linuxas3 postfix]# |
/etc/postfix/mysql_virtual.cf
[root@linuxas3 postfix]# cat /etc/postfix/mysql_virtual.cf #mysql_virtual.cf hosts = localhost user = postfix password= 6AJx9Nqv9x8hg dbname = postfix table = postfix_users select_field = maildir where_field = user [root@linuxas3 postfix]# |
/etc/postfix/mysql_aliases.cf
[root@linuxas3 postfix]# cat /etc/postfix/mysql_aliases.cf #mysql.aliases.cf hosts = localhost user = postfix password= 6AJx9Nqv9x8hg dbname = postfix table = postfix_aliases select_field = rcpt where_field = alias [root@linuxas3 postfix]# |
/etc/postfix/mysql_quota.cf
[root@linuxas3 postfix]# cat /etc/postfix/mysql_quota.cf #mailboxsize-mysql.cf hosts = localhost user = postfix password = 6AJx9Nqv9x8hg dbname = postfix table = postfix_users select_field = quota where_field = user [root@linuxas3 postfix]# |
运行,测试
postfix start
[root@linuxas3 src]# telnet localhost 25 Trying 127.0.0.1... Connected to linuxas3.9812.net (127.0.0.1). Escape character is '^]'. 220 mail.example.net ESMTP Postfix quit 221 Bye Connection closed by foreign host. [root@linuxas3 src]# |
卸载Postfix [2]
[1] | BSD 平台请使用下面命令:
| |
[2] | 复制下面命令粘贴到CLI上即可。
|