搭建postfix邮箱服务器

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.28

fa.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.rpm
warning: 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/aliases
alias_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 on 

8:测试发送邮件是否成功

[root@mail postfix]# echo 'txt body'|mail -s 'txt tile' xxx@163.com

查看日志

[root@mail mail]# tail -f /var/log/maillog 
Sep 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表示邮件已经发送成功

检查邮箱
邮件收到
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值