Sendmail配置策略
Sendmail.cf是Sendmail 配置文件,它全權(quán)決定了Sendmail的屬性。這個(gè)文件定義郵件服務(wù)器為哪個(gè)域工作。其中的內(nèi)容為特定宏,大多數(shù)人對(duì)它都抱有恐懼心理,因?yàn)槲募械暮甏a實(shí)在是太多。sendmail.cf通常是由一個(gè)以mc結(jié)尾的文件編譯產(chǎn)生。如Redhat自帶一個(gè)redhat.mc,用戶可以自己修改其中的一些設(shè)置,使之適合自己。
筆者的sendmail.mc 文件內(nèi)容如下:
- 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以產(chǎn)生需要的sendmail.cf文件:# m4 /etc/sendmail.mc > /etc/mail/sendmail.cf。
生成sendmail.cf以后,編輯sendmail.cf。在文件中,查找DS,在其后加入郵件服務(wù)器名、域名,這樣可以保證當(dāng)你以u(píng)sername@mail.domain.com或username@domain.com發(fā)信時(shí),用戶都可以收到,如下所示:
# Alias for this host
Cw mail.domain.com domain.com
然后,就可以啟動(dòng)Sendmail了:# /usr/sbin/Sendmail -bd -q20m。
Sendmail 8.9.x以后的版本,在缺省情況下,都默認(rèn)不對(duì)未驗(yàn)證的計(jì)算機(jī)進(jìn)行轉(zhuǎn)發(fā)(Relay),所以如果要為本機(jī)以外的其他計(jì)算機(jī)進(jìn)行郵件轉(zhuǎn)發(fā),這時(shí),應(yīng)該在相應(yīng)的配置文件中明確告訴Sendmail配置要對(duì)哪幾個(gè)主機(jī)進(jìn)行轉(zhuǎn)發(fā)。如果不考慮驗(yàn)證,對(duì)任何主機(jī)都進(jìn)行轉(zhuǎn)發(fā)的話,可以在sedmail.mc文件中加入一行:FEATURE(promiscuous_relay)。
不過,如果你的計(jì)算機(jī)是放在公網(wǎng)上的話,建議你不要這樣做,因?yàn)檫@樣做了以后,任何人都可以使用你的計(jì)算機(jī)進(jìn)行轉(zhuǎn)發(fā)郵件了,特別是一些別有用心的人或一些兜售客(spammer,垃圾郵件制造者)會(huì)利用你的郵件服務(wù)器的轉(zhuǎn)發(fā)功能亂發(fā)大量的垃圾郵件。
【編輯推薦】
- Linux sendmail配置、安裝和測(cè)試
- 使用php sendmail Windows下配置方法
- Sendmail 配置E-Mail服務(wù)器實(shí)現(xiàn)E-Mail靈活運(yùn)用
- Sendmail 配置E-Mail服務(wù)器開啟SMTP、POP端口
- Sendmail 安裝RPM包和編譯源碼