Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using telnet to send email
09-27-2013, 09:06 AM
Post: #1
Using telnet to send email
1 Envrionment:
Fedora 12 64bit 256Mb

2 Process:
1) Encode Username and Password with base64
The Format of telnet to connect remote server just like:
Code:
telnet hostname port
Because the username and password should be encode with base64 then they can be decode by remote machine. So before transmission these fields should be encode first. Assume the username and password both are 'test', then they can be encoded with 'base64' command like:
Code:
echo -n 'test' | base64
.The '-n' parameter used for preventing add '\n' character avoiding the error result. If not, It will be the encode result for string "test\n".
2)Email send test
(1)
The mailbox used here is 163.com and Its port is 25(almost mailboxs use 25). So the command like:
Code:
telnet smtp.163.com 25
thn it will return information like:
Code:
250-hz-b-163smtp2.163.com
250-mail
250-PIPELINING
250-8BITMIME
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 STARTTLS 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
.Last numbers and letter mean feedback information with encoded.
(2)
input the welcome information
Code:
EHLO smtp.163.com
then it will return information like:
Code:
250-hz-b-163smtp2.163.com
250-mail
250-PIPELINING
250-8BITMIME
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 STARTTLS 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
If not , Cheking carefully whether there is typing errors.
(3)
input username and password
input login command first:
Code:
AUTH LOGIN
It will return:
Code:
334 VXNlcm5hbWU6 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
then input username(encode with base64):
Code:
]dGVzdA==
it will return :
Code:
334 UGFzc3dvcmQ6 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
input password(encode with base64):
Code:
dGVzda==
If the return information like:
Code:
235 OK, go ahead (#2.0.0) 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
It means authorize successfully.If not, Checking carefully weather there is typing error or encoding error with base64
then input the mail sender:
Code:
MAIL FROM: test@163.com
Because we use test as username before, If type other username there will be an error that username don't match,If everything ok, it will return:
Code:
250 2.0.0 OK 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
the input the mail receiver:
Code:
RCPT TO:test@qq.com
it will return:
Code:
250 2.0.0 OK 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
then start to input context:
Code:
DATA
it will return :
Code:
354 Start mail input; end with <CRLF>.<CRLF> 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
start to input context such as:
Code:
TO:test@qq.com
FROM:test@163.com
SUBJECT:test by telnet/smtp

test, just a test

.
It use '<crlf>' + '." + '<crlf>' ended
end the connection:
Code:
QUIT
(The command above must be uppercase, using lowcase is invalid)
The information like bellow means the connection closed entirlly:
Code:
221 2.0.0 Bye 1a2e7e00-1c9d-4937-b0bd-426eed7dae42
Connection closed by foreign host.
Quote this message in a reply
08-30-2014, 10:49 PM
Post: #2
RE: Using telnet to send email
(09-27-2013 09:06 AM)cwt594252384 Wrote:  The Format of telnet to connect remote server just like:
Code:
telnet hostname port


to connect to a TLS-enabled SMTP servers, use this command:
Code:
openssl s_client -starttls smtp -crlf -connect server_address:port
Quote this message in a reply
12-27-2014, 09:17 PM
Post: #3
RE: Using telnet to send email
How about we move this thread to http://tab.d-thinker.org/forumdisplay.php?fid=79 ?

Wentao please also merge the content in #2 to the headpost.
Find all posts by this user
Quote this message in a reply
01-17-2016, 01:15 AM
Post: #4
RE: Using telnet to send email
(12-27-2014 09:17 PM)lingu Wrote:  How about we move this thread to http://tab.d-thinker.org/forumdisplay.php?fid=79 ?

Wentao please also merge the content in #2 to the headpost.

Please take a look at the request above.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: