Send Email via Port 587 with Openssl

Please refer to the steps below to send Email via Port 587 with openssl

Telnet cannot be used as once you issues STARTTLS, the session will be encrypted and you will not be able to enter any commands

Port 587 – Securing SMTP communications using Transport Layer Security (TLS). STARTTLS

Prepare your username & password with PowerShell

#Convert your username to BASE64
$Username  = [System.Text.Encoding]::UTF8.GetBytes("[email protected]")
[System.Convert]::ToBase64String($Username)

#Convert your Password to BASE64
$Password = [System.Text.Encoding]::UTF8.GetBytes("P@ssw0rd")
[System.Convert]::ToBase64String($Password)

#Decode BASE64 back to normal text 
$DecodeBase64  = [System.Convert]::FromBase64String("bTN0ZXN0QGJlbmFsZWMuY29tLm15")
[System.Text.Encoding]::UTF8.GetString($DecodeBase64)

Open MobaXterm and enter the following commands

you can install openssl with “apt-get install openssl” if you have not done so

#Connect to port 587 with Starttls 
openssl s_client -starttls smtp -crlf -connect 10.3.3.23:587

#Enter helo / ehlo
helo 

#Login using Username & Password (BASE64 Format)
auth login

334 VXNlcm5hbWU6
XXXXXXXXXXXXXXXXXXX #Username (BASE64) here 
334 UGFzc3dvcmQ6
XXXXXXXXXXXXXXXX #Password (BASE64) here

235 2.7.0 Authentication successful

#Standard SMTP Telnet commands here
    mail from:<[email protected]> 
250 2.1.0 Sender OK
    rcpt to:<[email protected]>
250 2.1.5 Recipient OK
    data
354 Start mail input; end with <CRLF>.<CRLF>
    subject: My Test Email 
    helo, 
    Testing Email 
    . #put . here to stop and start to deliver the email 
250 2.6.0 <[email protected]> [InternalId=72026601553977, Hostname=mail.test.com] Queued mail for delivery

Leave a Comment

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

Scroll to Top