How to send an email through telnet with authentication

First you need to convert your username to Base64

$ echo “username” | base64
dXNlcm5hbWUK

Next convert your password to Base 64

$ echo “password” | base64
cGFzc3dvcmQK

Then you can connect to the server through telnet

telnet mail.example.com 587
Trying 192.168.1.100…
Connected to mail.example.com.
Escape character is ‘^]’.
220 mail.example.com ESMTP Postfix
ehlo mail.example.com
250-mail.example.com
250-PIPELINING
250-SIZE 20971520
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH LOGIN
334 VXNlcm5hbWU6
dXNlcm5hbWUK
334 UGFzc3dvcmQ6
cGFzc3dvcmQK
235 2.7.0 Authentication successful
MAIL FROM: <matt@mail.example.com>
250 2.1.0 MAIL ok
RCPT TO: <support@mail.example.com>
250 2.1.5 <support@mail.example.com> ok
DATA
354 send message
From: “Matt” <matt@mail.example.com>
To: “Support” <support@mail.example.com>
Subject: test message sent from manual telnet session with authetcation
Date: Fri, 30 March 2018 14:05:00 -0600
Hello World,
This is a test message with telnet authentication
.
250 2.0.0 Ok: queued as F348C500290
quit
221 2.0.0 Bye

Leave a Reply

Your email address will not be published. Required fields are marked *