http://www.51testing.com/?uid-205133-action-viewspace-itemid-196958
http://postfix.state-of-mind.de/patrick.koetter/smtpauth/smtp_auth_mailclients.html
https://help.ubuntu.com/community/Postfix
smtp login auth
=========先计算BASE64编码的用户名密码
认证登录需要用到===========
[crazywill@localhost crazywill]$ perl -MMIME::Base64 -e 'print encode_base64("myusername");'
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: # 邮件发送方
553 You are not authorized to send mail, authentication is required # 不可伪造发送邮件
MAIL FROM: # 邮件发送方
250 Mail OK
RCPT TO: # 邮件的接收方,若有多个收件人,则重复这一语句多次。
250 Mail OK
DATA # 邮件体内容
354 Please start mail input.
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]$
smtp plain auth
$ telnet server.example.com 25
. . .
220 server.example.com ESMTP Postfix
EHLO client.example.com
250-server.example.com
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-AUTH DIGEST-MD5 PLAIN CRAM-MD5
250 8BITMIME
AUTH PLAIN AHRlc3QAdGVzdHBhc3M=
235 Authentication successful
Instead of AHRlc3QAdGVzdHBhc3M=, specify the base64 encoded form of \0username\0password (the \0 is a null byte). The example above is for a user named `test' with password `testpass'.
In order to generate base64 encoded authentication information you can use one of the following commands:
% printf '\0username\0password' | mmencode
% perl -MMIME::Base64 -e \
'print encode_base64("\0username\0password");'
The mmencode command is part of the metamail software. MIME::Base64 is available from http://www.cpan.org/.
Caution: when posting logs of the SASL negotiations to public lists, please keep in mind that username/password information is trivial to recover from the base64-encoded form.
======================开始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)
SUBJECT: test by telnet/smtp # 邮件主题
Message-Id: <44A91687.0E6F6C.07562>
Date: Mon, 3 Jul 2006 21:07:19 +0800 (CST)
.
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)
SUBJECT: test by telnet/smtp
Message-Id: <44A91687.0E6F6C.07562>
Date: Mon, 3 Jul 2006 21:07:19 +0800 (CST)
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要传送的数据里。
bdat命令:
输入:bdat 100 last后再输入100个字符服务器就会自动返回250 Requested mail action okay, completed
认证:
AUTH LOGIN
会一次提示你
334 VXNlcm5hbWU6
和
334 UGFzc3dvcmQ6
后边的内容是提示输入用户名和口令,信息是经过base64编码的
输入的用户名和口令也要经过编码,这里是一个编码、解码的工具
smtp认证通过后会显示
235 2.0.0 Authentication successful