如何在Linux下安裝Sendmail伺服器軟體的方法

來源:互聯網
上載者:User

   1、從www.sendmail.org下載最新的版本(這個snedmail倒是有必要升級為最新的版本,因為它的升級主要是安全性漏洞問題)。這裡說明的是用的sendmail-8.12.2.tar.gz

  2、cd /usr/local/src/

  3、把檔案下載到:/usr/local/src中

  4、tar zxvf sendmail-8.12.2.tar.gz

  5、cd /usr/local/src/sendmail-8.12.2

  6、chmod go-w / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue

  7、chown root / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue

  8、cd /usr/local/src/sendmail-8.12.2/sendmail

  9、sh Build

  10、cd /usr/local/src/sendmail-8.12.2/cf/cf

  11、建立檔案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 pacage installed for this to work.

  include(`/usr/local/src/sendmail-8.12.2/cf')

  define(`confDEF_USER_ID',`8:12')

  OSTYPE(`linux')

  undefine(`UUCP_RELAY')

  undefine(`BITNET_RELAY')

  define(`confTO_CONNECT', `1m')

  define(`confTRY_NULL_MX_LIST',true)

  define(`confDONT_PROBE_INTERFACES',true)

  define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')

  define(`SMART_HOST',compaq.rd.xxx.com)

  <---這條用於(非HUB)預設使用HUB發送郵件

  MASQUERADE_AS(`rd.xxx.com')

  <-------------------------

  FEATURE(`masquerade_entire_domain')

  <---這三條用於郵件地址偽裝

  FEATURE(`masquerade_envelope')

  <-------------------------

  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)

  FEATURE(`access_db')

  FEATURE(`blacklist_recipients')

  FEATURE(`accept_unresolvable_domains')

  MAILER(smtp)

  MAILER(procmail)

  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.

  dnl FEATURE(`relay_based_on_MX')

  12、sh Build install-cf

  13、groupadd smmsp

  14、useradd smmsp

  15、cd cd /usr/local/src/sendmail-8.12.2/sendmail

  16、sh Build install

  17、cd /usr/local/src/sendmail-8.12.2/makemap

  18、sh Build clean

  19、sh Build all

  20、sh Build install

  21、cd /usr/local/src/sendmail-8.12.2/

  22、在本域DNS主要資料庫檔案中增加MX紀錄:

  rd.xxx.com. IN MX 0 compaq

  注意修改相應部分。那個0是有幾個郵件集中器的時候用於標記先後順序的。當有好幾個MX的時候,建議順序寫為10、20、30…

  23、在/etc/mail目錄下建立access檔案,內容類別似如下:

  127.0.0.1 RELAY

  21.9.22 RELAY

  211.99.221.238 RELAY

  然後:makemap hash access.db < access

  24、建立檔案/etc/mail/local-host-names,其內容為原生擁有的網域名稱資訊。

  rd.xxx.com

  compaq.rd.xxx.com

  25、建立檔案/etc/mail/aliases,內容類別似:

  MAILER-DAEMON: postmaster

  postmaster: root

  bin: root

  daemon: root

  nobody: root

  運行newaliases建立資料庫。

  建立別名檔案的意義之一在於當郵件發往域中其他郵件伺服器的使用者而不是mail HUB使用者的時候用。

  比如增加一條:

  atan: atan@fbsd

  則導致郵件發往mail HUB的時候自動轉寄到atan@fbsd.rd.xxx.com

  26、啟動sendmail: /usr/sbin/sendmail -bd -q30m

  排錯:如果有問題導致啟動不了,大部分問題和DNS配置有關,可以使用nslookup檢查DNS是否正常。挨個檢查/etc/mail中的檔案內容也是排錯的好辦法。另外,修改配置,不建議直接編輯sendmail.cf檔案,建議使用m4宏編譯工具,因為有些帶有安全性漏洞或過時的宏在編譯的時候會有提示,這樣以免造成相關安全問題。

  通過上面文章,我們應該瞭解了在Linux下安裝Sendmail伺服器的方法,希望對你們有協助!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.