資料來源 :
http://www.gentoo.org.tw/got-doc/postfix.xml
內容: 1. Postfix 安裝手冊2. 建置一個完善的郵件伺服器3. 安裝 Xinetd4. 安裝 uw-imap5. 安裝 cyrus-sasl6. 安裝 Postfix7. 測試除錯[@more@]
1. Postfix 安裝手冊
什麼是 Postfix
Postfix 是由 Wietse Venema's (http://www.porcupine.org/wietse/) 開發用來替代使用最廣的 Sendmail 程式;此外,Postfix 試圖在使用上更快速 、簡單管理及安全,同時與 sendmail 保持足夠的相容性而不打擾系統中已存在的使用者。 尤其近來 Sendmail 經常被發現 local root 的攻擊漏洞加上 Sendmail 發展已久, 在安裝及設定上並不是那麼簡單,所以有許多單位或網管人員逐漸改採 Postfix 來做 為郵件轉遞的代理者(MTA,Mail Transfer Agent)
2. 建置一個完善的郵件伺服器
Postfix+Pop3+Smtp
由於安裝郵件伺服器必須支援POP3+SMTP 這兩個協定所以必須要安裝Imap(POP3), 要啟動Imap必須先具備Xinetd,如果已經安裝了那可以跳過Xinetd的安裝步驟, 並接者安裝cyrus-sasl(SMTP)最後開始設定Postfix 就可以完成整個安裝與設定的步驟 由於本篇文章只指導安裝所需之步驟,如有其他概念性的問題請參考其他網站所作之介紹, 本篇就不再多說
3. 安裝 Xinetd
當我們安裝好 Xinetd 之後千萬要記得把它加入到開機的啟動程序當中
原始碼3.1: 安裝 Xinetd |
# emerge xinetd # rc-update add xinetd default |
4. 安裝 uw-imap
當我們安裝好 Imap 的時候預設值是不會啟動各種協定的包括 POP3, 所以我們必須去手動修改設定值讓他能夠自動開啟 POP3 協定
原始碼4.1: 安裝並設定 imap |
# emerge uw-imap # nano -w /etc/xinetd.d/ipop3 # default: off # $Header: /home/cvsroot/gentoo-x86/net-mail/uw-imap/files/uw-ipop3.xinetd,v 1. # description: The POP3 service allows remote users to access their mail # using an POP3 client such as Netscape Communicator, mutt, # or fetchmail. service pop-3 { socket_type = stream wait = no user = root server = /usr/sbin/ipop3d log_on_success += USERID log_on_failure += USERID disable = yes } # /etc/init.d/xinetd restart |
5. 安裝 cyrus-sasl
原始碼5.1: 安裝設定 Cyrus-sasl |
# emerge cyrus-sasl # nano -w /etc/sasl2/smtpd.conf pwcheck_method:saslauthd
# rc-update add saslauthd default |
6. 安裝 Postfix
接者我們可以安裝 Postfix 了,不過要注意 USE FLAG 參數部份要先加入 sasl 以及 Mbox 或者 Maildir
原始碼6.1: 安裝設定 Postfix |
# nano -w /etc/make.conf USE=" " # emerge postfix # nano -w /etc/postfix/main.cf
alias_database = hash:/etc/mail/aliases alias_maps = hash:/etc/mail/aliases command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/lib/postfix debug_peer_level = 2 default_destination_concurrency_limit = 2 inet_interfaces = all local_destination_concurrency_limit = 2 mail_owner = postfix mail_spool_directory = /var/spool/mail
mailbox_size_limit = 52428800
mailq_path = /usr/bin/mailq manpage_directory = /usr/share/man message_size_limit = 10485760
mydestination = $myhostname, localhost.$mydomain $mydomain
mydomain = focuses.org
myhostname = mail.focuses.org
mynetworks_style = subnet myorigin = $myhostname newaliases_path = /usr/bin/newaliases queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.0.16-r1/readme relay_domains = focuses.org
sample_directory = /usr/share/doc/postfix-2.0.16-r1/sample sendmail_path = /usr/sbin/sendmail setgid_group = postdrop unknown_local_recipient_reject_code = 450 smtpd_client_restrictions = permit_sasl_authenticated
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
存檔離開 # /etc/init.d/postfix restart |
7. 測試除錯
原始碼7.1: 測試是否有啟動 SASL 認證機制 |
# telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mail.focuses.org ESMTP Postfix ehlo localhost 250-mail.focuses.org 250-PIPELINING 250-SIZE 10485760 250-VRFY 250-ETRN 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN NTLM
250-XVERP 250 8BITMIME quit 221 Bye Connection closed by foreign host. |
原始碼7.2: 除錯 |
# nano -w /var/log/messages
範例一 postfix/local[508]: fatal: open database /etc/mail/aliases.db: No such file or directory
# newaliases
範例二 warning: smtpd_sasl_auth_enable is true, but SASL support is not compiled in
# USE="sasl" emrege postfix
範例三 安裝 Postfix 的時候可能出現的問題 # emerge postfix Calculating dependencies ...done!
!!! Error: the virtual/mta package conflicts with another package. !!! both can't be installed on the same system together. !!! Please use 'emerge --pretend' to determine blockers.
# qpkg -I -v smtp net-mail/ssmtp-2.48 * # emerge -C ssmtp-2.48 |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/786540/viewspace-1002823/
,如需转载,请注明出处,否则将追究法律责任。