1.关掉sendmail相关的所有服务,最好是直接卸载sendmail.
# service sendmail stop# chkconfig sendmail off
#rpm -qa | grep sendmail | xargs rpm -e
2.安装postfix.
redhat6.0以上版本应该是默认集成了postfix服务的,假如没有安装的话,可以手动安装。
rpm -qa | grep postifx (查看是否安装)
yum install postfix
3.安装完成后,修改配置文件:/etc/postfix/main.cfg
vi /etc/postfix/main.cfmyname = sample.test.com ← 设置系统的主机名mydomain = test.com ← 设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)myorigin = $mydomain ← 将发信地址“@”后面的部分设置为域名(非系统主机名)inet_inteces = all ← 接受来自所有网络的请求mydestination = $myname, local.$mydomain, local, $mydomain ← 指定发给本地邮件的域名home_mailbox = Maildir/ ← 指定用户邮箱目录
<保存退出!>
4.为本机添加DNS server.
为什DNS Server?因为在邮件发送过程中,需要把邮件地址的domain地址转化成IP地址,再去发送给对应的收件人,这里涉及到DNS中的A记录和MX记录相关的知识,不熟悉的同学可以google或者百度 脑补一下 :-)
如何添加DNS server呢,DNS server去哪里寻找?
vim /etc/resolv.conf
添加如下行:
nameserver 8.8.8.8
nameserver 8.8.4.4
上面用的8.8.8.8/8.8.4.4是Google Free DNS server,当然还有很多免费的DNS server供大家使用,可以google一下:-)
5.测试一下邮件是否能够发送成功:
命令行输入$: > echo Mail Content | mail -s Mail Subject xxxx@xxx.com
Note:if you see below warings after you run above command.
send-mail: warning: inet_protocols: IPv6 support is disabled: Address family not supported by protocolsend-mail: warning: inet_protocols: configuring for IPv4 support onlypostdrop: warning: inet_protocols: IPv6 support is disabled: Address family not supported by protocolpostdrop: warning: inet_protocols: configuring for IPv4 support only
that means you don't have IPv6 configured in your OS's network stack, but your mailer (presumably postfix) is configured to use IPv6. Since there is no IPv6 for your mailer to use, it's warning you that it's only going to use IPv4.
To disable the waring messsage, go to /etc/postfix/main.cf and change from:
inet_protocols = all
to:
inet_protocols = ipv4
This will only use ipv4 and the warning message will go away.
You will have to issue a stop and start for postfix to register the change.
service postfix restart
6.查看log,确认邮件发送状态:
路易斯彩票首页 邮件的log位置是:/var/log/maillog
发送成功的话,会返回250和OK,也可以去自己的邮件客户端查收。
一切OK的话,那路易斯彩票首页 mail service应该就搭建成功了。
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
另外一些有用的postfix维护命令,一遍日常的检测和维护:
mailq :会列出当前在postfix发送队列中的所有邮件
postsuper -d ALL:删除当前等待发送队列的所有邮件,包括发送失败的退信
当然还有很多,就不一一列举了,大家可以网上搜索扩展,Good Luck!
7.Update Mail From sender
echo do-not-reply@example.com root@example.com >> /etc/postfix/generic echo tp_generic_maps = hash:/etc/postfix/generic >>/etc/postfix/main.cf postmap /etc/postfix/genericservice postfix restart