安裝postfix
postfix是一個快速、易于管理、安全性高的郵件發送服務,可以配合dovecot實作一個完美的郵箱伺服器。
1、安裝postfix
[root@localhost ~]# rpm -qa | grep postfix
[root@localhost ]# yum install -y postfix
Loaded plugins: fastestmirror, refresh-packagekit, security
Complete!
[root@localhost]#
2、配置postfix,編輯配置檔案“/etc/postfix/main.cf”
[root@localhost ~]# gedit /etc/postfix/main.cf
mydomain = david.cn //dns中的域名
myhostname = mailsrv.david.cn //dns中的域名
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
inet_interfaces = all //允許處理所有網路資訊
inet_protocols = all //允許ipv4和ipv6
mynetworks = 192.168.0.0/24, 127.0.0.0/8 //允許接入的ip段
3、設定防火牆,postfix使用25端口
[root@localhost ~]# gedit /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
[root@localhost ~]# service iptables restart
iptables:将鍊設定為政策 ACCEPT:filter nat [确定]
iptables:清除防火牆規則: [确定]
iptables:正在解除安裝子產品: [确定]
iptables:應用防火牆規則: [确定]
iptables:載入額外子產品:nf_conntrack_ftp [确定]
4、啟動服務
[root@localhost ~]# service postfix start
啟動 postfix: [确定]
[root@localhost ~]#
5、連接配接測試
[root@localhost ~]# telnet 192.168.0.113 25 //ip是本機位址,25是端口号
Trying 192.168.0.113...
Connected to 192.168.0.113.
Escape character is '^]'.
220 mailsrv.david.cn ESMTP Postfix
6、發信
[root@localhost ~]# mail david //給david發信,確定此使用者存在Linux系統中。發信人是目前登入的使用者root
Subject: test04 //标題
hello david //内容
. //結束
EOT
[root@localhost ~]# mail -u david //檢視使用者david的信件
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/mail/david": 5 messages 1 new
1 root Thu Aug 16 17:07 21/692 "test"
2 root Thu Aug 16 17:08 20/631 "test"
3 root Thu Aug 16 17:10 20/602 "test"
4 root Fri Aug 17 08:15 20/570 "test3"
>N 5 root Fri Aug 17 09:46 18/539 "test04" //此信件是剛才收到的,由root使用者發出
&