=========先計算BASE64編碼的用戶名密碼,認證登錄需要用到===========
[crazywill@localhost crazywill]$ perl -MMIME::Base64 -e 'print encode_base64("crazywill");'
Y3Jhenl3aWxs
[crazywill@localhost crazywill]$ perl -MMIME::Base64 -e 'print encode_base64("mypassword");'
bXlwYXNzd29yZA==
======================開始SMTP發信操作==========================
[crazywill@localhost crazywill]$ telnet smtp.163.com 25 #telnet登錄25端口
Trying 202.108.5.81...
Connected to smtp.163.com.
Escape character is '^]'.
220 163.com Coremail SMTP(Anti Spam) System
EHLO smtp.163.com # 握手 :)
250-mail
250-PIPELINING
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
AUTH LOGIN # 開始認證登錄
334 dXNlcm5hbWU6
crazywill
334 UGFzc3dvcmQ6
mypassword
535 Error: authentication failed # 直接用戶名密碼不能登錄
AUTH LOGIN
334 dXNlcm5hbWU6
Y3Jhenl3aWxs
334 UGFzc3dvcmQ6
bXlwYXNzd29yZA==
235 Authentication successful # 使用Base64編碼則成功登錄
MAIL FROM:<test@163.com> # 郵件發送方
553 You are not authorized to send mail, authentication is required # 不可偽造發送郵件
MAIL FROM:<crazywill@163.com> # 郵件發送方
250 Mail OK
RCPT TO:<crazywill@163.com> # 郵件的接收方,若有多個收件人,則重復這一語句多次。
250 Mail OK
DATA # 郵件體內容
354 Please start mail input.
TO: crazywill@163.com # 此處的TO,FROM,等內容,可以隨便造假 :) 可以騙人但騙不了懂得查看郵件源碼的。
FROM: cccc@163.com
SUBJECT: test by telnet/smtp
test, just a test. # 郵件正文內容,與Header部分空一行開始寫
. # 郵件寫完,以一個句點加回車結果。
250 Mail OK queued as smtp10,wKjADQ2ApxRnnqBE0CWaEw==.38326S3 # 返回250 表示發送成功。
NOOP # 空語句,不執行任何操作,一般用來保持和服務器連接,不要掉線
250 OK
QUIT # 退出
221 Closing connection. Good bye.
Connection closed by foreign host.
[crazywill@localhost crazywill]$
======================開始POP3收信操作==========================
[crazywill@localhost crazywill]$ telnet pop.163.com 110 #telnet登錄110端口
Trying 202.108.5.104...
Connected to pop.163.com.
Escape character is '^]'.
+OK Welcome to coremail Mail Pop3 Server (163com[20050206])
USER crazywill # 用戶名
+OK core mail
PASS mypassword # 登錄密碼
+OK 254 message(s) [27676669 byte(s)]
STAT # 查看郵箱狀態
+OK 254 27676669
LIST # 郵件列表
+OK 254 27676669
1 2468
2 21945
3 33136
4 2071
5 3364
6 18906
7 3136
8 24764
.................
TOP 254 0 # 查看指定郵件的郵件頭,0表示查看整個郵件頭,其它正整數表示限制返回多少行。
+OK core mail
Received: from smtp.63.com (unknown [58.252.70.158])
by smtp5 (Coremail) with SMTP id wKjREDrA9gIfFqlEjCnRAg==.29062S4;
Mon, 03 Jul 2006 21:07:18 +0800 (CST)
TO: crazywill@163.com
FROM : cccc@163.com # 這里即前面發信時偽造的一個假發送人信息,平時正常操作只顯示這個。
SUBJECT: test by telnet/smtp # 郵件主題
Message-Id: <44A91687.0E6F6C.07562>
Date: Mon, 3 Jul 2006 21:07:19 +0800 (CST)
Sender: crazywill@163.com # 這里是真正的發送人,不可偽造。
.
RETR 254 # 獲取指定郵件
+OK 354 octets
Received: from smtp.63.com (unknown [58.252.70.158])
by smtp5 (Coremail) with SMTP id wKjREDrA9gIfFqlEjCnRAg==.29062S4;
Mon, 03 Jul 2006 21:07:18 +0800 (CST)
TO: crazywill@163.com
FROM : cccc@163.com
SUBJECT: test by telnet/smtp
Message-Id: <44A91687.0E6F6C.07562>
Date: Mon, 3 Jul 2006 21:07:19 +0800 (CST)
Sender: crazywill@163.com
test, just a test.
.
DELE 254 # 刪除第254封郵件
+OK core mail
STAT # 查看郵箱狀態
+OK 253 27676315
QUIT # 退出
+OK core mail
Connection closed by foreign host.
[crazywill@localhost crazywill]$
===============================================================
QUESTION:
如何發送給多人,如何CC,BCC?
ANSWER: (此答案由SnifferPro監聽OUTLOOK發送多人郵件分析出來的)
同一封信發送/抄送給多人,在MAIL FROM:<...> 后,多次使用 RCPT TO:<...>
每次一個郵件地址,需要發給多少人就 RCPT TO 多少次。
在DATA里面寫的CC,BCC,TO,等信息只起顯示作用,與實際發送人接收人無關。
CC與BCC的差別:同樣都是RCPT TO指定收件人,但是郵件客戶端程序,不會將BCC的收件人寫到DATA要傳送的數據里。
使用IMAP
[crazywill@localhost crazywill]$
telnet 192.168.0.1 143 #telnet登錄IMAP協議的143端口
Trying 192.168.0.1...
Connected to xxxxxx
Escape character is '^]'.
* OK xxxxxxx System IMap Server Ready
A01 LOGIN abc 123 #用戶登錄
A01 OK LOGIN completed
A02 LIST "" * #列出所有信箱列表
* LIST () "/" "INBOX"
* LIST () "/" "Drafts"
* LIST () "/" "Sent Items"
* LIST () "/" "Trash"
* LIST () "/" "Junk E-mail"
* LIST () "/" "Virus Items"
* LIST () "/" "&XfJT0ZABkK5O9g-"
* LIST () "/" "&g0l6Pw-"
* LIST () "/" "&XfJT0ZABkK5O9g-/DailyReport"
* LIST () "/" "Jira"
* LIST () "/" "Admin"
* LIST () "/" "&V4NXPpCuTvY-"
A02 OK LIST Completed
A03 Select INBOX #選擇收件箱
* 37 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1] UIDs valid
* FLAGS (\Answered \Seen \Deleted \Draft)
* OK [PERMANENTFLAGS (\Answered \Seen \Deleted \Draft)] Limited
A03 OK [READ-WRITE] SELECT completed
A04 Search ALL #查詢收件箱所有郵件
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* SEARCH 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
A04 OK SEARCH completed # 列出符合條件的郵件序號(ALL表示列出當前信箱INBOX中的所有郵件)
A05 Search new #查詢收件箱所有新郵件
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* OK X-SEARCH in progress
* SEARCH
A05 OK SEARCH completed #找不到任何新郵件
A06 Fetch 5 full #獲取第5封郵件的郵件頭
* 5 FETCH (INTERNALDATE "27-Jun-2006 14:00:27 +0800" FLAGS (\Seen) ENVELOPE ("Tue, 27 Jun 2006 13:56:51 +0800" "test " (("xxxxxx" NIL "xxxx" "xxxxxx")) (("xxxxxx" NIL "xxxx" "xxxxxx")) (("xxxxxx" NIL "xxxx" "xxxxxx")) ((NIL NIL "xxx" "xxxxx")) NIL NIL NIL "<
000f01c699ae$7c5014a0$6b01a8c0@xxxxxx.xx>") BODY (("text" "plain" ("charset" "gb2312") NIL NIL "base64" 14 2) ("text" "html" ("charset" "gb2312") NIL NIL "base64" 420 7) "alternative") RFC822.SIZE 1396)
A06 OK Fetch completed
A07 Fetch 5 rfc822 #獲取第5封郵件的完整內容
* 5 FETCH (RFC822 {1396}
[這里是郵件內容,太長,略...]
A07 OK Fetch completed
A08 Fetch 5 flags #查詢第5封郵件的標志位
A08 OK Fetch completed
A09 Store 5 +flags.silent (\deleted) #設置標志位為刪除
A09 OK STORE completed
A10 Expunge #永久刪除當前郵箱INBOX中所有設置了\deleted標志的信件
A10 OK EXPUNGE completed
A11 noop # 空語句
A11 OK NOOP completed
A20 LOGOUT #退出
* BYE IMAP4rev1 Server logging out
A20 OK LOGOUT completed
Connection closed by foreign host.
[crazywill@localhost crazywill]$