Postfix
postfix是WietseVenema在IBM的GPL協議之下開發的MTA(郵件傳輸代理)軟件。postfix是WietseVenema想要爲使用最廣泛的sendmail提供替代品的一個嘗試。在Internet世界中,大部分的電子郵件都是通過sendmail來投遞的,大約有100萬用戶使用sendmail,每天投遞上億封郵件。這真是一個讓人吃驚的數字。Postfix試圖更快、更容易管理、更安全,同時還與sendmail保持足夠的兼容性。
特點
免費
postfix想要作用的範圍是廣大的Internet用戶,試圖影響大多數的Internet上的電子郵件系統,因此它是免費的。
更快
postfix在性能上大約比sendmail快三倍。一部運行postfix的臺式PC每天可以收發上百萬封郵件。
兼容性好
postfix是sendmail兼容的,從而使sendmail用戶可以很方便地遷移到postfix。Postfix支持/var【/spool】/mail、/etc/aliases、NIS、和~/.forward文件。
更健壯
postfix被設計成在重負荷之下仍然可以正常工作。當系統運行超出了可用的內存或磁盤空間時,postfix會自動減少運行進程的數目。當處理的郵件數目增長時,postfix運行的進程不會跟着增加。
更靈活
postfix是由超過一打的小程序組成的,每個程序完成特定的功能。可以通過配置文件設置每個程序的運行參數。
安全性
postfix具有多層防禦結構,可以有效地抵禦惡意***者。如大多數的postfix程序可以運行在較低的權限之下,不可以通過網絡訪問安全性相關的本地投遞程序等等。
郵件隊列(mailqueues)
postfix有四種不同的郵件隊列,並且由隊列管理進程統一進行管理:
1.maildrop:本地郵件放置在maildrop中,同時也被拷貝到incoming中。
2.incoming:放置正在到達或隊列管理進程尚未發現的郵件。
3.active:放置隊列管理進程已經打開了並正準備投遞的郵件,該隊列有長度的限制。
4.deferred:放置不能被投遞的郵件。
隊列管理進程僅僅在內存中保留active隊列,並且對該隊列的長度進行限制,這樣做的目的是爲了避免進程運行內存超過系統的可用內存。
模塊的管理文件/etc/postfix/master.cf
postfix主配置文檔/etc/postfix/main.cf
指令postconf-d默認參數
-n新參數
-e編輯
postconf-e“參數”
一:地址驗證
1【本地域名】mydomain=a.com
2【本地主機名稱】myhostname=mail.a.com
3【郵件地址僞裝】myorigin=$mydomain
4【確定監聽地址】inet_interfaces=all
5【確定本地信件】mydestination=$myhostname,localhost.$mydomain,localhost,$mydomain
6【設置中繼,基於地址】mynetworks=192.168.20.0/24,127.0.0.0/8
登錄到本地地址發送郵件:
Trying192.168.20.100...
Connectedto192.168.20.100(192.168.20.100).
Escapecharacteris'^]'.
220a.comESMTPPostfix
ehlomail.a.com
250-a.com
250-PIPELINING
250-SIZE10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250DSN
mailfrom:[email protected]
2502.1.0Ok
rcptto:[email protected]
2502.1.5Ok
data
354Enddatawith<CR><LF>.<CR><LF>
subject:ok
adjshjk
.
2502.0.0Ok:queuedas03EABFFA4E
quit
可以發送郵件但是沒有身份驗證
二:.賬號驗證
broken_sasl_auth_clients=yes
smtpd_sasl_auth_enable=yes
smtpd_sasl_security_options=noanonymous
#smtpd_sasl_application_name=smtpd
#smtpd_client_restrictions=permit_sasl_authenticated,reject
#smtpd_client_restrictions=permit_sasl_authenticated
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
servicepostfixrestart
[root@localhostServer]#telnet192.168.20.10025
Trying192.168.20.100...
Connectedto192.168.20.100(192.168.20.100).
Escapecharacteris'^]'.
220a.comESMTPPostfix
ehlomail.a.com
250-a.com
250-PIPELINING
250-SIZE10240000
250-VRFY
250-ETRN
250-AUTHPLAINLOGIN驗證的信息
250-AUTH=PLAINLOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250DSN
雖然設置驗證機制,默認是不進行強制驗證,任何人都還是可以發
[root@localhostServer]#telnet192.168.20.10025
Trying192.168.20.100...
Connectedto192.168.20.100(192.168.20.100).
Escapecharacteris'^]'.
220a.comESMTPPostfix
mailfrom:[email protected]
2502.1.0Ok
rcptto:[email protected]
2502.1.5Ok
data
開啓驗證服務,servicesaslauthdstart
並且打開smtpd_client_restrictions=permit_sasl_authenticated,reject
禁掉smtpd_client_restrictions=permit_sasl_authenticated
broken_sasl_auth_clients=yes
smtpd_sasl_auth_enable=yes
smtpd_sasl_security_options=noanonymous
#smtpd_sasl_application_name=smtpd
smtpd_client_restrictions=permit_sasl_authenticated,reject
#smtpd_client_restrictions=permit_sasl_authenticated
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
再次發送郵件客戶端主機被拒絕發信
[root@localhostServer]#telnet192.168.20.10025
Trying192.168.20.100...
Connectedto192.168.20.100(192.168.20.100).
Escapecharacteris'^]'.
220a.comESMTPPostfix
mailfrom:[email protected]
2502.1.0Ok
rcptto:[email protected]
5545.7.1<unknown[192.168.20.100]>:Clienthostrejected:Accessdenied
如果能通過驗證,不是本地地址的郵件也可以往外發,在配置文件裏去掉192.168.20.0這個網段的地址,打開postfix的配置文件
mynetworks=127.0.0.0/8
[root@localhost~]#echo-n"[email protected]"|opensslbase64
dXNlcjFAYS5jb20=
[root@localhost~]#echo-n"123"|opensslbase64
MTIz
[root@localhostServer]#telnet192.168.20.10025
Trying192.168.20.100...
Connectedto192.168.20.100(192.168.20.100).
Escapecharacteris'^]'.
220a.comESMTPPostfix
authlogindXNlcjFAYS5jb20=
334UGFzc3dvcmQ6
MTIz
2352.0.0Authenticationsuccessful
mailfrom:[email protected]
2502.1.0Ok
rcptto:[email protected]
2502.1.5Ok