Centos 6.x Postfix Server安裝設定與啟用

Postfix安裝

yum install postfix

CentOS 5之前預設的Mail Server服務是Sendmail,而在CentOS 6 後即是以Postfix當作預設的 Mail Server,Postfix比起Sendmail在設定上更容易上手,因此不需要像網路上其它的教學安裝system-switch-mail,因為system-switch-mail是用來將Sendmail切換成Postfix。
Postfix最主要的功能則是啟動SMTP的服務,也就是架設一台MTA(Mail Transfer Agent)。

Postmail的主要設定都在 /etc/postfix/main.cf

vi /etc/postfix/main.cf

尋找

"#myhostname ="字串,預設會看到"#myhostname = host.domain.tld"和"#myhostname = virtual.domain.tld"這二行字串

請在這二行後面增加以下的字串設定即可

myhostname = pentax.cf

尋找

#mydomain = 字串,預設會看到#mydomain =domain.tld

新增一行如下

mydomain = pentax.cf

尋找

#myorigin = $myhostname
#myorigin = $mydomain
myorigin = $mydomain 字串,將#移除

搜尋以下字串

#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = localhost

修改成

inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost

把postfix加到開機自啟動

chkconfig postfix on

重啟postfix就可以利用smtp的服務收發信件

service postfix restart

檢查SMTP服務是否開啟,如果有的話,輸入下列命列,會看到Port 25正在監聽的狀態

netstat -tlunp | grep ':25'

測試postfix

telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 pentax.cf ESMTP Postfix
quit

如果postfix還是無法寄出 mail
那就要修改 php.ini

vi /usr/local/php/etc/php.ini

找到sendmail_path的字串
把他改成

sendmail_path = /usr/sbin/sendmail -t -i

重起php 再試看看

8201517374_0afe81153a_o

上一篇 Google Chrome小密技
下一篇 如何在Linux中添加Swap空間