事前準備:
用mail指令送信
- # mail -s 'my test' aaa@gmail.com --->mail -s 標題 email位址
- hello, I'd likt to buy many things --->輸入信件內容後,按enter
- . --->結束信件內容輸入小數點,按enter
- Cc: --->輸入信件副本
- [root@localhost ~]# netstat -tanlp | grep 25
- tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3059/sendmail: acce
- #vi /var/named/chroot/var/named/ne226.zone
- www IN A 140.137.217.226
- w3 IN A 140.137.217.226
- @ IN MX 10 mail --->@代表"ne226.kirnel.com.",權重=10
- mail IN A 140.137.217.226
安裝步驟:
1.架設sendmail必要套件
- #rpm -qa | egrep 'sendmail | m4' --->查詢是否有安裝
- sendmail-8.13.8-2.el5
m4-1.4.5-3.el5.1
sendmail-cf-8.13.8-2.el5
- #vi /etc/mail/local-host-names
- # local-host-names - include all aliases for your machine here.
- ne226.kirnel.com --->加上網域名稱
3.允許外部ip連線 25 port
- #vi /etc/mail/sendmail.mc --->將127.0.0.1改成0.0.0.0
- DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
4.轉換mc檔為cf格式檔
- #cd /etc/mail
- #m4 sendmail.mc > sendmail.cf
- #service sendmail restart
6.測試port25-在windows輸入以下指令
- c:>telnet 140.137.217.226 25
- HELO yourname - 通知 SMTP Server 你是誰(在linux mail server上有帳號)
MAIL FROM: email@server.com - 寄件者電郵地址
RCPT TO: email@smtpserver.com - 收件者電郵地址
DATA - 以上步驟通過後,可以用 DATA 開頭並輸入信件內容,結束時用 “.”
QUIT - 離開用 QUIT 結束
7.寄信給在主機上有帳號的人
應用:
加入某網段,使sendmail願意為其傳送信件(寄件者用的pc所在的網段)
- 用gmail寄信給hello@ne226.kirnel.com
- $cd /var/spool/mail
- $mail --->列出hello的新信
- $&1--->讀取第一封
- $more --->按空白鍵
- $&q --->離開
應用:
加入某網段,使sendmail願意為其傳送信件(寄件者用的pc所在的網段)
- #vi /etc/mail/access
- Connect:localhost.localdomain RELAY
- Connect:localhost RELAY
- Connect:127.0.0.1 RELAY
- Connect:140.137.217 RELAY
- #makemap hash access.db < access --->將access文字檔轉換成access.db格式
- #service sendmail restart
- 可以用outlook以hello@ne226.kirnel.com寄信給gmail帳號
- #cd /etc/dovercot/
- protocols = imap imaps pop3 pop3s
- #service dovecot restart
- 可以用outlook取得hello@ne226.kirnel.com的信件
Note:
信件讀完會被放在使用者的家目錄下:/home/hello/mbox
linux的郵局:/var/spool/mail
mail的log : /var/log/maillog
讚!
回覆刪除