Sendmail配置策略

來源:互聯網
上載者:User

Sendmail.cf是Sendmail 設定檔,它全權決定了Sendmail的屬性。這個檔案定義郵件伺服器為哪個域工作。其中的內容為特定宏,大多數人對它都抱有恐懼心理,因為檔案中的宏代碼實在是太多。sendmail.cf通常是由一個以mc結尾的檔案編譯產生。如Redhat內建一個redhat.mc,使用者可以自己修改其中的一些設定,使之適合自己。


筆者的sendmail.mc 檔案內容如下:

 
  1. divert(-1)  
  2. dnl This is the macro config file used to generate the /etc/sendmail.cf  
  3. dnl file. If you modify thei file you will have to regenerate the  
  4. dnl /etc/sendmail.cf by running this macro config through the m4  
  5. dnl preprocessor:  
  6. dnl m4 /etc/sendmail.mc > /etc/sendmail.cf  
  7. dnl You will need to have the Sendmail-cf package installed for this to work.  
  8. include(`/usr/lib/Sendmail-cf/m4/cf.m4')  
  9. define(`confDEF_USER_ID',``8:12'')  
  10. OSTYPE(`linux')  
  11. undefine(`UUCP_RELAY')  
  12. undefine(`BITNET_RELAY')  
  13. define(`confAUTO_REBUILD')  
  14. define(`confTO_CONNECT', `1m')  
  15. define(`confTRY_NULL_MX_LIST',true)  
  16. define(`confDONT_PROBE_INTERFACES',true)  
  17. define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')  
  18. FEATURE(`smrsh',`/usr/sbin/smrsh')  
  19. FEATURE(`mailertable',`hash -o /etc/mail/mailertable')  
  20. FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')  
  21. FEATURE(redirect)  
  22. FEATURE(always_add_domain)  
  23. FEATURE(use_cw_file)  
  24. FEATURE(local_procmail)  
  25. MAILER(smtp)  
  26. MAILER(procmail)  
  27. FEATURE(`access_db')  
  28. FEATURE(`blacklist_recipients')  
  29. dnl We strongly recommend to comment this one out if you want to protect  
  30. dnl yourself from spam. However, the laptop and users on computers that do  
  31. dnl not hav 24x7 DNS do need this.  
  32. FEATURE(`accept_unresolvable_domains')  
  33. 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,垃圾郵件製造者)會利用你的郵件伺服器的轉寄功能亂髮大量的垃圾郵件。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.