Plain Text Email:
To test the basic, unauthenticated SMTP services on a server, here's what you'll need. This is all happening without authentication or encryption, so not used very often anymore.
What you'll need: any telnet client like PuTTY or the Windows Telnet Client
How to connect:
- telnet <smtp.server.name> 25
- ehlo <domain.name>
- mail from: <email address>
- rcpt to: <email address>
- data
- subject: <Enter mail subject line here>
- <Write your email text here>
- <press enter twice then . to send>
How it looks:
Note that these messages are typically not going to make it through modern SPAM and Phishing filters.
Encrypted but not authenticated email:
To test a StartTLS connection, you'll first need an SSL client like OpenSSL. On Windows 11, you can use winget to install one:
- winget install --id=FireDaemon.OpenSSL -e
- $Env:PATH += ";C:\Program Files\FireDaemon OpenSSL 3\bin"
On a Linux machine, you can also install via their package managers.
To initiate the StartTLS connection to, say, Office 365, use this command:
- openssl s_client -starttls smtp -connect smtp.office365.com:587
Then proceed to run through the above ehlo, mail from:, mail to:, and data commands.
Encrypted and Authenticated emails:
If you've gotten this far, you should already have OpenSSL installed on your station. We'll need this to authenticate to our email server. This one will require some copy / paste so have a notepad open also.
Begin by getting Base64 encoded strings of your username and password:
- echo -n '<emailaddress>' | openssl base64
- echo -n '<password>' | openssl base64
Now we can connect back to our session, but we'll need a few extra commands before we can send email:
- openssl s_client -starttls smtp -connect smtp.office365.com:587
- helo <domain.name>
- auth login
- paste the Base64-encoded username
- paste the Base64 encoded password
- you should be an authentication success message, but I always just got "DONE" so...
--- ACTUALLY ---
I was having tons of trouble with the openssl method. But this PowerShell method worked for me, for the time being at least. It's deprecated and it's not recommended to use it.
$cred = Get-Credential
$emailto='nate@nordicpc.com'
$emailfrom='copier@sevendevils.net'
$smtpserver='smtp.office365.com'
$MailMessage = @{
To = $emailto
From = $emailfrom
Subject = "Testing SMTP TLS on O365"
Body = "This is a test message. Hello! "
Smtpserver = $smtpserver
#ErrorAction = "SilentlyContinue"
Port="587"
}
Send-MailMessage @MailMessage -UseSsl -Credential $cred
