ps -aux | grep sendmail killall sendmail
並在設定中關閉相關服務:
sendmail_enable="YES" sendmail_flags="-bd" sendmail_outbound_enable="NO" sendmail_submit_enable="NO" sendmail_msp_queue_enable="NO"
以下假設你已安裝 apache。
cd /usr/ports/mail/postfix make install clean
安裝過程中會問是否要加裝附加元件,全部不選直接按 OK;問到是否建立帳號時按 yes。
先備份 main.cf 再編輯:
cd /usr/local/etc/postfix cp main.cf main.cf.orig vi main.cf
確認 mail_owner 為 postfix(預設即是),然後加入或修改:
mail_owner = postfix alias_maps = hash:/usr/local/etc/postfix/aliases mynetworks_style = host mydestination = $myhostname, localhost.$mydomain, freefall.$mydomain, mail3.$mydomain relaydomain = $mydestination mailbox_size_limit = 102400000 # 郵箱 100M disable_vrfy_command = yes # 關閉 vrfy smtpd_recipient_limit = 100 # 單封信可寄的人數
把 aliases 轉成 db:
cd /usr/local/etc/postfix postalias hash:aliases # 或 newaliases
access 檔用來做存取限制,格式為「設定對象 設定方式」,對象可用主機名、IP、網域或郵件位址,方式主要為 REJECT 與 OK:
cd /usr/local/etc/postfix postmap hash:access # 產生 access.db
postfix start # 啟動 postfix stop # 停止 postfix reload # 重載
telnet localhost 25 HELO localhost 250 Ok DATA 354 End data with . This is a short test of the SMTP email system. . 250 Ok: queued as F341A379 QUIT 221 Bye
Postfix 搞定。
cd /usr/ports/mail/qpopper make install clean
把 inetd 設定中的這行:
#pop3 stream tcp nowait root /usr/local/libexec/popper popper
改成:
pop3 stream tcp nowait root /usr/local/libexec/qpopper qpopper -s
若 inetd 未運行就啟動它,已在運行則重載:
/usr/sbin/inetd & kill -HUP <inetd 的 pid>
測試:
telnet localhost 110 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. QUIT Connection closed by foreign host.
cd /usr/ports/mail/openwebmail make install
全部完成。實務上建議再補上 TLS/SASL 與 SPF、黑名單等抗垃圾郵件機制,並把 25 與 110 埠的開放範圍收斂到防火牆規則中。