Sending mail to a SMTP server using telnet

$ telnet remotehost 25
HELO localhost
MAIL FROM: johndoe@localhost
RCPT TO: jilldoe@remotehost
DATA
Subject:Test Message
This is a test message.
.
QUIT

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

smtp auth checking

Generate base64 encoded authentication string:

echo -ne '\000username\000password' | openssl enc -base64

or with perl:

perl -MMIME::Base64 -e 'print encode_base64("\000username\000password");'

Replace the username and password respectively. "\000" is a null byte character used as the separator between username and password:

It prints something like:

AHVzZXJuYW1lAHBhc3N3b3Jk

Copy that string and simulate a login session:

telnet remotehost 25

Example session transcript is below (bold is to be typed):

220 remotehost ESMTP Sendmail...
EHLO remotehost
250-remotehost Hello localhost, pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
250-STARTTLS
250-DELIVERBY
250 HELP
AUTH PLAIN AHVzZXJuYW1lAHBhc3N3b3Jk
235 2.0.0 OK Authenticated
QUIT

"OK Authenticated" would mean the authentication was successful.

Since the server offer "STARTTLS" session, to test TLS encrypted session, use openssl instead of telnet:

openssl s_client -connect {remotehost}:25 -starttls smtp

Comment