Testing SMTPS from Command Line (with Authentication)

Just like the testing of SMTP using Telnet, you can also perform the same steps if the target server is using TLS, however because telnet won’t do the job here, you can use OpenSSL instead.

Here’s a simple example.

Firstly get your Username and Password in Base64 format.

echo -n "username" | base64
echo -n "password" | base64

You’ll get the Base64 encoded strings outputted after each command. Now you can make the connection and authenticate.

Notice the -quiet at the end of the command, this is needed to ensure that if your username or password string contain “Q” it doesn’t just quit the command, see https://superuser.com/questions/1179522/why-do-i-get-done-after-auth-login-command-to-smtp-server for more details on this.

openssl s_client -starttls smtp -crlf -connect mail.domain.com:587 -quiet

ehlo senderdomain.com

auth login

auth login
334 VXNlcm5hbWU6
<Base64 encoded username>
334 UGFzc3dvcmQ6
<Base64 encoded password>
235 2.7.0 Authentication successful

mail from:info@senderdomain.com
rcpt to:info@domain.com
data
To:info@domain.com
From:info@senderdomain.com
Subject:A Test Message for You!
Hello,
How are you?
Thanks
Tristan
.

Leave a comment