telnet工具利用SMTP協議發送郵件


SMTP(Simple Mail Transfer Protocol):簡單郵件傳輸協議

郵件的發送,主要是通過SMTP協議來實現的

一、使用telnet客戶端工具使用SMTP協議發送郵件

1、windows系統中啟用telnet客戶端工具

打開控制面板【右鍵左下角windows圖標,點運行輸入 control】,選擇 程序 ==>  啟用或關閉windows功能 ==> 找到 Telnet Client 勾選 ==> 點確定 啟用telnet工具

 

 

2、使用 telnet 連接郵件服務器25端口

[root@17:10:48 ~]# telnet mail.domain.com 25
Trying 192.168.1.121...
Connected to mail.domain.com.
Escape character is '^]'.
220 mail.domain.com Anti-spam 

3、使用EHLO指令與郵件服務器握手

 1 [root@17:10:48 ~]# telnet mail.domain.com 25
 2 Trying 192.168.1.121...
 3 Connected to mail.domain.com.
 4 Escape character is '^]'.
 5 220 mail.domain.com Anti-spam 
 6 EHLO mail.domain.com  7 250-mail.domain.com
 8 250-PIPELINING
 9 250-SIZE 1024000000
10 250-VRFY
11 250-ETRN
12 250-AUTH PLAIN LOGIN
13 250-AUTH=PLAIN LOGIN
14 250-ENHANCEDSTATUSCODES
15 250-8BITMIME
16 250 DSN

4、使用AUTH LOGIN 來對自己的用戶進行登陸,賬號和密碼需要經過 base64編碼 之后輸入

 1 [root@17:10:48 ~]# telnet mail.domain.com 25
 2 Trying 192.168.1.121...
 3 Connected to mail.domain.com.
 4 Escape character is '^]'.
 5 220 mail.domain.com Anti-spam 
 6 EHLO mail.domain.com
 7 250-mail.domain.com
 8 250-PIPELINING
 9 250-SIZE 1024000000
10 250-VRFY
11 250-ETRN
12 250-AUTH PLAIN LOGIN
13 250-AUTH=PLAIN LOGIN
14 250-ENHANCEDSTATUSCODES
15 250-8BITMIME
16 250 DSN
17 AUTH LOGIN
18 334 VXNlcm5hbWU6
19 aGFoYUBkb21haW4uY29tCg 20 334 UGFzc3dvcmQ6
21 MTIzNDU2Cg 22 235 2.7.0 Authentication successful

5、發送郵件

 1 [root@17:10:48 ~]# telnet mail.domain.com 25
 2 Trying 192.168.1.121...
 3 Connected to mail.domain.com.
 4 Escape character is '^]'.
 5 220 mail.domain.com Anti-spam 
 6 EHLO mail.domain.com
 7 250-mail.domain.com
 8 250-PIPELINING
 9 250-SIZE 1024000000
10 250-VRFY
11 250-ETRN
12 250-AUTH PLAIN LOGIN
13 250-AUTH=PLAIN LOGIN
14 250-ENHANCEDSTATUSCODES
15 250-8BITMIME
16 250 DSN
17 AUTH LOGIN
18 334 VXNlcm5hbWU6
19 aGFoYUBkb21haW4uY29tCg
20 334 UGFzc3dvcmQ6
21 MTIzNDU2Cg
22 235 2.7.0 Authentication successful
23 MAIL FROM: <haha@domain.com>
24 250 2.1.0 Ok
25 RCPT TO:<zcq@xxx.com>
26 250 2.1.5 Ok
27 DATA 28 354 End data with <CR><LF>.<CR><LF>
29 Date:12 Apr 1992 00:00:00
30 From: "測試郵件Telnet "<haha@domain.com>
31 To:<zcq@xxx.com>
32 Subject:Telnet發送的測試郵件,xxxxxx!
33 Content-type: text/plain;charset="gb2312"
34 Content-Transfer-Encoding: 7bit
35 
36 來自舊時代的測試郵件。
37 
38 
39 . 40 250 2.0.0 Ok: queued as A76CA27B5
41 quit 42 221 2.0.0 Bye
43 Connection closed by foreign host.

 

6、登陸收件箱驗證郵件,有可能被反垃圾程序隔離,沒收到查下垃圾箱

 

二、常用SMTP命令

1、常用命令:

NOOP                測試發件服務器用,正常郵件服務器會返回 ok 應答

HELO            客戶端為標識自己的身份而發送的命令(通常帶域名) :HELO   mail.domain.com

EHLO                 使服務器可以表明自己支持擴展簡單郵件傳輸協議(ESMTP)命令 : EHLO  mail.domain.com

MAIL  FROM      標識郵件的發件人:  MAIL FROM:  <haha@domain.com>

RCPT  TO          標識郵件的收件人:  RCPT TO:  <xixi@test.com>

DATA                  將命令之后的內容作為郵件數據傳輸給收件服務器,直到輸入單行 點 .  為結束輸入

RSET                 重置會話,當前傳輸被取消

QUIT                  終止會話

 

2、常見SMTP命令響應碼

211  System status, or system help reply   【系統狀態或系統幫助響應】
214  Help message  【幫助信息】
220  <domain> Service ready  【服務就緒】
221  <domain> Service closing transmission channel  【服務關閉】
250  Requested mail action okay, completed  【請求的郵件操作完成】
251  User not local; will forward to <forward-path>  【不是本地用戶,將轉發到 < 轉發路徑/地址 >】
354  Start mail input; end with <CRLF>.<CRLF> 【開始郵件輸入,以回車 點 回車 結束】
421  <domain> Service not available, closing transmission channel 【服務不可用,關閉傳輸通道】
451  Requested action aborted: local error in processing  【請求的操作中止:處理過程中的本地錯誤】
452  Requested action not taken: insufficient system storage  【未采取的請求操作:系統存儲不足】
455  Server unable to accommodate parameters 【服務器無法容納參數】
500  Syntax error, command unrecognized (This may include errors such as command line too long)  【語法錯誤,命令無法識別(這可能包括命令行太長等錯誤)】
504  Command parameter not implemented 【命令參數未實現】
550  Requested action not taken: mailbox unavailable (e.g., mailbox not found, no access, or command rejected for policy reasons)【【請求操作未被執行:郵箱不可用(例如,郵箱未找到,不能訪問,或命令拒絕政策原因】】
552  Requested mail action aborted: exceeded storage allocation 【請求的郵件操作中止:超出存儲分配】
553  Requested action not taken: mailbox name not allowed (e.g.,mailbox syntax incorrect) 【未執行請求操作:不允許使用郵箱名稱(例如,郵箱語法不正確)】
554  Transaction failed (Or, in the case of a connection-opening response, "No SMTP service here") 【事務失敗(或者,在連接打開響應的情況下,“這里沒有SMTP服務”)】
555  MAIL FROM/RCPT TO parameters not recognized or not implemente【郵件從/RCPT到參數未識別或未實現】

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM