linux系統SendMail詳細配置

1、 安裝相關服務
DNS
Mailserver(sendmail、imap)
2、 啓動相關服務
Service named restart
Service sendmail restart
Service xinetd restart
Chkconfig ipop3 on
3、 配置DNS,添加MX紀錄
配置DNS略
正/反向區間文件添加MX紀錄
IN MX 10(優先級) mail.anniey.com
Mail IN A 192.168.1.100
4、 主配置文件
/etc/mail/sendmail.cf
搜索/smtp
Port=smtp,Addr=192.168.1.100
5、 接受域配置文件
Vi /etc/mail/local-host-names
添加
Anniey.com
192.168.1.100
6、中繼轉發配置文件
/etc/mail/access.db(不可訪問)
Vi /etc/mail/access
添加
Anniey.com
192.168.1
退出
Makemap hash access.db < access
6、 添加用戶
Useradd user01
Passwd user01

Useradd user02
Passwd user02
7、 重啓服務
Service sendmail restart
Service xinetd restart

補:郵件用戶別名,郵件域別名
A)用戶別名
1、Vi /etc/aliases
別名 用戶名
A01 user01
A02 user02
退出
2、Newaliases

B)郵件域別名
1、配置相關DNS略
2、添加域別名
Vi /etc/mail/sendmail.cw
Anniey.com
Johnny.com
退出
3、接受域配置文件
Vi /etc/mail/local-host-names
Anniey.com
Johnny.com
192.168.1.100
4、重啓服務
Service named restart
Service sendmail restart
Service xinetd restart

補:啓用smtp認證
1、 安裝相關模塊
Rpm –qa | grep sasl
Linux盤中:RedHat—〉RPMS—>sasl*
2、 修改 /etc/mail/sendmail.mc(sendmail.cf的源代碼)
Vi /etc/mail/sendmail.mc
查詢:43 TRUST_AUTH*
:44
:85 DAEMON_OPTION*
:92 DAEMON*
注:去掉dnl(註釋)
3、 生成sendmail.cf
M4 sendmail.mc >sendmail.cf
4、刪除部分中繼,以免開後門
5、客戶機
我的服務器要求身份驗證

經過以上步驟後,應該就可以用Outlook Express正常發送郵件了,但這時還不能用Outlook Express從服務器端收取郵件的,因爲sendmail默認狀態並不具備POP3功能,我們還得自己安裝並啓用它。
1、安裝pop3服務
  rpm -qa imap
  imap-2001a-18
  rpm -ivh imap-2001a-18.i386.rpm
  2.啓用POP3服務。
  POP3服務:請先修改/etc/xinetd.d/ipop3文件,將其中的disable=yes改爲disable=no後保存;然後重新啓動xinetd程序來讀取這個修改過的配置文件,使之生效。
  /etc/rc.d/init.d/xinetd restart







* 利用telnet 命令發送郵件 :
用telnet SMTP發送郵件(僞裝163發給Gmail)
xuanfei@xuanfei-desktop:~$  telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Fri, 10 Aug 2007 19:27:20 +0800
helo root
250 localhost.localdomain Hello localhost [127.0.0.1] (may be forged), pleased to meet you
mail from: [[email protected]][color=#0000ff][email protected][/color][/email]   
250 2.1.0 [[email protected]][color=#0000ff][email protected][/color][/email]... Sender ok
rcpt [url=http://to:shutup:[email protected]/]to:shutup:[email protected][/url]
250 2.1.5 [[email protected]][color=#0000ff][email protected][/color][/email]... Recipient ok
data.
500 5.5.1 Command unrecognized: "data."
data
354 Enter mail, end with "." on a line by itself
who are you:(
.
250 2.0.0 l7ABRKF5006423 Message accepted for delivery
quit
221 2.0.0 localhost.localdomain closing connection
Connection closed by foreign host.
xuanfei@xuanfei-desktop:~$

如果服務器smtp需要驗證,helo完要輸入
AUTH LOGIN
會一次提示你
334 VXNlcm5hbWU6

334 UGFzc3dvcmQ6
後邊的內容是提示輸入用戶名和口令,信息是經過base64編碼的
輸入的用戶名和口令也要經過編碼,這裏是一個編碼、解碼的工具
smtp認證通過後會顯示
235 2.0.0 Authentication successful

在用data命令之後可以直接書寫正文,但也按照下面的“mime-version:”、“from:”、“to:”、“cc:”、“subject:”、“content-type:” 等固定的格式分別進行書寫。會讓E-mail的顯示及郵件頭比較完整,如下:
mime-version: 1.0
from: xuanfei2046<[[email protected]][color=#0000ff][email protected][/color][/email]>
to: xuanfei<[[email protected]][color=#0000ff][email protected][/color][/email]>
cc: xuanfei2046 <[[email protected]][color=#0000ff][email protected][/color][/email]>
subject: helo
Content-Type: text/plain;charset="GB2312"



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章