Sendmail配置策略
Sendmail.cf是Sendmail 配置文件,它全權決定了Sendmail的屬性。這個文件定義郵件服務器為哪個域工作。其中的內容為特定宏,大多數人對它都抱有恐懼心理,因為文件中的宏代碼實在是太多。sendmail.cf通常是由一個以mc結尾的文件編譯產生。如Redhat自帶一個redhat.mc,用戶可以自己修改其中的一些設置,使之適合自己。
筆者的sendmail.mc 文件內容如下:
- divert(-1)
- dnl This is the macro config file used to generate the /etc/sendmail.cf
- dnl file. If you modify thei file you will have to regenerate the
- dnl /etc/sendmail.cf by running this macro config through the m4
- dnl preprocessor:
- dnl m4 /etc/sendmail.mc > /etc/sendmail.cf
- dnl You will need to have the Sendmail-cf package installed for this to work.
- include(`/usr/lib/Sendmail-cf/m4/cf.m4')
- define(`confDEF_USER_ID',``8:12'')
- OSTYPE(`linux')
- undefine(`UUCP_RELAY')
- undefine(`BITNET_RELAY')
- define(`confAUTO_REBUILD')
- define(`confTO_CONNECT', `1m')
- define(`confTRY_NULL_MX_LIST',true)
- define(`confDONT_PROBE_INTERFACES',true)
- define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')
- FEATURE(`smrsh',`/usr/sbin/smrsh')
- FEATURE(`mailertable',`hash -o /etc/mail/mailertable')
- FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')
- FEATURE(redirect)
- FEATURE(always_add_domain)
- FEATURE(use_cw_file)
- FEATURE(local_procmail)
- MAILER(smtp)
- MAILER(procmail)
- FEATURE(`access_db')
- FEATURE(`blacklist_recipients')
- dnl We strongly recommend to comment this one out if you want to protect
- dnl yourself from spam. However, the laptop and users on computers that do
- dnl not hav 24x7 DNS do need this.
- FEATURE(`accept_unresolvable_domains')
- dnl FEATURE(`relay_based_on_MX')
Sendmail配置編譯sendmail.mc以產生需要的sendmail.cf文件:# m4 /etc/sendmail.mc > /etc/mail/sendmail.cf。
生成sendmail.cf以后,編輯sendmail.cf。在文件中,查找DS,在其后加入郵件服務器名、域名,這樣可以保證當你以username@mail.domain.com或username@domain.com發信時,用戶都可以收到,如下所示:
# Alias for this host
Cw mail.domain.com domain.com
然后,就可以啟動Sendmail了:# /usr/sbin/Sendmail -bd -q20m。
Sendmail 8.9.x以后的版本,在缺省情況下,都默認不對未驗證的計算機進行轉發(Relay),所以如果要為本機以外的其他計算機進行郵件轉發,這時,應該在相應的配置文件中明確告訴Sendmail配置要對哪幾個主機進行轉發。如果不考慮驗證,對任何主機都進行轉發的話,可以在sedmail.mc文件中加入一行:FEATURE(promiscuous_relay)。
不過,如果你的計算機是放在公網上的話,建議你不要這樣做,因為這樣做了以后,任何人都可以使用你的計算機進行轉發郵件了,特別是一些別有用心的人或一些兜售客(spammer,垃圾郵件制造者)會利用你的郵件服務器的轉發功能亂發大量的垃圾郵件。
【編輯推薦】
- Linux sendmail配置、安裝和測試
- 使用php sendmail Windows下配置方法
- Sendmail 配置E-Mail服務器實現E-Mail靈活運用
- Sendmail 配置E-Mail服務器開啟SMTP、POP端口
- Sendmail 安裝RPM包和編譯源碼