# yum remove postfix ##删除系统自带postfix
# userdel postfix
# groupdel postdrop
# groupadd -g 2525 postfix
# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
# groupadd -g 2526 postdrop
# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
yum install httpd mysql mysql-server mysql-devel openssl openssl-devel dovecot dovecot-mysql tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect expect-devel gcc gcc-c++ cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGI perl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel telnet libicu-devel -y
安装postfix
wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-2.10.0.tar.gz
tar xf postfix-2.10.0.tar.gz
cd postfix-2.10.0
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lrt -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto'
make
make install
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 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 final destination directory for the Postfix on-line
manual pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man]
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 directory for Postfix queues.
queue_directory: [/var/spool/postfix]
Please specify the final destination directory for the Postfix README
files. Specify "no" if you do not want to install these files.
readme_directory: [no]
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 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]
[root@ipython ~]# newaliases #生成别名文件
[root@ipython ~]# ll /etc/aliases.db
-rw-r--r-- 1 root root 12288 Jul 8 13:24 /etc/aliases.db
测试邮件发送
[root@ipython postfix]# telnet localhost 25 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 ipython.localdomain ESMTP Postfix ehlo localhost 250-ipython.localdomain 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN mail from:root@localhost 250 2.1.0 Ok rcpt to:deo@localhost 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> Subject:hello test . 250 2.0.0 Ok: queued as AF46E2615D4 quit 221 2.0.0 Bye Connection closed by foreign host.
部署dns
[root@mail ~]# yum install bind bind-utils -y
[root@mail ~]# hostname
mail.deo.com
# vi /etc/named.conf # listen-on port 53 { 127.0.0.1; }; # listen-on-v6 port 53 { ::1; }; ##注释或删除以上两行 [root@mail ~]# cat /etc/named.rfc1912.zones #到最后添加如下内容 zone "deo.com" IN { type master; file "deo.com.zone"; allow-update { none; }; allow-transfer { none; }; }; zone "80.16.172.in-addr.arpa" IN { type master; file "172.16.80.zone"; allow-update { none; }; allow-transfer { none; }; };
[root@mail ~]# named-checkconf /etc/named.conf #检查配置