1:修改hostname(先关闭防火墙)
修改教程http://blog.csdn.net/weeknd/article/details/74202118
格式是mail.xxx.com
2:解析DNS[root@mail ~]# hostname
mail.fa.com[root@mail ~]# more /proc/sys/kernel/hostname
mail.fa.com[root@mail ~]# host fa.com
fa.com has address 178.77.89.28fa.com mail is handled by 10 ds178-77-89-8.dedicated.hosteurope.de.
3:卸载sendmail[root@mail ~]# service sendmail stop
[root@mail ~]# yum remove sendmail
4:安装postfix
[root@mail Packages]# rpm -ivh postfix-2.6.6-6.el6_5.x86_64.rpmwarning: postfix-2.6.6-6.el6_5.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing... ########################################### [100%]
package postfix-2:2.6.6-6.el6_5.x86_64 is already installed
[root@mail Packages]# rpm -qa|grep postfix
postfix-2.6.6-6.el6_5.x86_64
5:备份main.cf
[root@mail Packages]# cd /etc/postfix/
[root@mail postfix]# ls
access canonical generic header_checks main.cf master.cf relocated transport virtual
[root@mail postfix]# cp main.cf main.cf.bak
6:修改main.cf[root@mail postfix]# vi mail.cf
修改的信息(核对修改)
[root@mail mail]# /usr/sbin/postconf -n
alias_database = hash:/etc/aliasesalias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/ -----419行设置邮件路径(home_mailbox=Mailbox也需要开启)
html_directory = no
inet_interfaces = all -----116行postfix监听端口
inet_protocols = ipv4 -----119行postfix支持的协议类型
mail_owner = postfix
mail_spool_directory = /data/mail -----425行邮件存储路径
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ----164行接收邮件的主机名和域名
mydomain = fa.com -----83行填写域名
myhostname = mail.fa.com -----75行填写配置的hostname
mynetworks = 127.0.0.0/8 -----264行设置网络可以转发的地址(此项填写的值表示无需smtp认证)
myorigin = $mydomain -----99行引用域名
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
7:重启postfix
[root@mail mail]# service iptables stop[root@mail mail]# service iptables start
设置开机自动启动
[root@mail mail]# chkconfig postfix on8:测试发送邮件是否成功
[root@mail postfix]# echo 'txt body'|mail -s 'txt tile' xxx@163.com查看日志
[root@mail mail]# tail -f /var/log/maillogSep 18 16:12:02 mail postfix/pickup[3305]: 2E117180878: uid=0 from=<root>
Sep 18 16:12:02 mail postfix/cleanup[3311]: 2E117180878: message-id=<20170918081202.2E117180878@mail.fa.com>
Sep 18 16:12:02 mail postfix/qmgr[3306]: 2E117180878: from=<root@fa.com>, size=420, nrcpt=1 (queue active)
Sep 18 16:12:27 mail postfix/smtp[3313]: 2E117180878: to=<xxx@163.com>, relay=163mx03.mxmail.netease.com[220.181.14.160]:25, delay=25, delays=0.07/0.01/25/0.17, dsn=2.0.0, status=sent (250 Mail OK queued as mx45,X8CowEBJw0ztf79ZGX91JA--.8118S2 1505722349)
Note:250 mail ok表示邮件已经发送成功
检查邮箱邮件收到