lee-pai-long
1/20/2016 - 2:24 PM

telnet-smtp.md

[TELNET] SMTP

Connect to the server

$ telnet <servername_or_ip> <port>

(Default port : 25)

Polite people says Hello first

> EHLO <servername>

Authentification

First encode username and password in B64:

$ perl -MMIME::Base64 -e 'print encode_base64("<username>");'
$ perl -MMIME::Base64 -e 'print encode_base64("password");'

Then inside the telnet

> AUTH LOGIN

the server returns:

> 334 VXNlcm5hbWU;

B64 encoded string asking for username

Paste the base64 encoded username:

> dXNlcm5hbWU=

Then the server returns:

> 334 UGFzc3dvcmQ6;

B64 encoded string asking for password

Paste the B64 encoded password:

> cGFzc3dvcmQ=

Now the server should return:

> 235 Authentication succeeded

Define Sender

> MAIL FROM:<sender@domain.tld>

The server should return:

> 250 2.1.0 Ok

Warning : Even if the sender is wrong or not authorized the server always return Ok, because the checking is done with both sender and recipient

Define Recipient

> RCPT TO:<recipient@domain.tld>

The server should return:

> 250 2.1.0 Ok

Insert DATA

> DATA

the server returns:

> 354 End data with <CR><LF>.<CR><LF>

Enter actual mail content:

> From: sender@example.com
> To: recipient@example.com
> Subject: Test message
> Reply-to: sender@example.com
> This is a test message.

Then press enter, a dot then enter again:

> 250 2.6.0 Queued mail for delivery

Disconnect

> QUIT

the server returns :

> 221 <servername> ESMTP <serverbannner> closing connection