Send An Email over Openssl

To send an email over openssl from Linux you only need an open terminal and the openssl package installed. Then it is simply a matter of opening a connection to your server and sending it some commands. It is the same commands that your GUI mail client will be using.

Send An Email Over OpenSSL

Sort out the encrypted data

We will need to encrypt some data,

Plain Text Encrypted Value
UserName: VXNlcm5hbWU6
fred@dragon.lab ZnJlZEBkcmFnb24ubGFi
Password UGFzc3dvcmQ6
MYSQLPassword01! TVlTUUxQYXNzd2QwMSE=

To encrypt and decrypt your own data values, perform a Google search to find an online encoder, I used this one.

Sending the Email

The following is how to send an email over openssl using TLS.
When sending emails you need to start the data part with a subject line as show in the box below. Followed by a blank line, and then the body of the email can be sent.

Subject: Your subject

This must be followed by a blank line. The remaining text until the first full stop at the start of a new line will be the message body. If you do not use the quiet command line option the certificate is down loaded with the initial response.

Only enter the data in bold, do not enter the data in ‘(this is a comment)’
openssl s_client -quiet -connect localhost:587 -starttls smtp
openssl s_client -quiet -connect localhost:587 -starttls smtp
depth=2 O = Digital Signature Trust Co., CN = DST Root CA X3
verify return:1
depth=1 C = US, O = Let’s Encrypt, CN = Let’s Encrypt Authority X3
verify return:1
depth=0 CN = mail.dragon.lab
verify return:1
250 SMTPUTF8
EHLO dragon.lab
250-mailserver.dragon.lab
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
AUTH LOGIN
334 VXNlcm5hbWU6 (decoded this is Username:)
ZnJlZEBkcmFnb24ubGFi (this is fred@dragon.lab encoded)
334 UGFzc3dvcmQ6 (decoded this is Password:)
TVlTUUxQYXNzd2QwMSE= (This is the encoded password)
235 2.7.0 Authentication successful
MAIL FROM: fred@dragon.lab
250 2.1.0 Ok
RCPT TO: fred@dragon.lab
250 2.1.5 Ok
DATA
354 End data with .
Subject: Your first test email with SMTP over TLS

Hello,

This is your first test email.

Fred
.

250 2.0.0 Ok: queued as E27D466454
quit
221 2.0.0 Bye

Now we have sent an email, why not take a look at https://blogging.dragon.org.uk/test-a-pop3-mailserver/ or https://blogging.dragon.org.uk/testing-imap-mailserver/ to read it back.

Leave a Reply

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