Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SMTP test email using AWS Simple Email Service (SES) on UNIX openssl s_client or Windows PowerShell
# Source: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-client-command-line.html
# X-SES-CONFIGURATION-SET is optional
EHLO yourdomain.com
AUTH LOGIN
base64 encoded Smtp Username
base64 encoded Smtp Password
MAIL FROM: from@yourdomain.com
RCPT TO: email@anydomain.com
DATA
#X-SES-CONFIGURATION-SET: YourSESConfigSet
From: Your Nice Name <from@yourdomain.com>
To: email@anydomain.com
Cc: cc@anydomain.com
Bcc: invisible@anydomain.com
Subject: Hello from Amazon SES SMTP Test for UNIX
This message was sent using the Amazon SES SMTP interface.
There is no more content in this test email.
.
QUIT
# Change 'eu-west-1' according to your AWS SES SMTP setup!
# Explicit SSL over port 587
$ openssl s_client -crlf -quiet -starttls smtp -connect email-smtp.eu-west-1.amazonaws.com:587 < unix-aws-ses-testmail.txt
# Implicit SSL over port 465
$ openssl s_client -crlf -quiet -connect email-smtp.us-west-2.amazonaws.com:465 < unix-aws-ses-testmail.txt
<# Source:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-client-command-line.html
#>
$EmailFrom = "from@yourdomain.com"
$EmailTo = "email@anydomain.com"
$Subject = "Hello from Amazon SES SMTP Test for Windows"
$Body = "This message was sent using the Amazon SES SMTP interface. There is no more content in this test email."
$SMTPServer = "email-smtp.eu-west-1.amazonaws.com" # Change 'eu-west-1' according to your AWS SES SMTP setup!
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("base64 encoded Smtp Username", "base64 encoded Smtp Password");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Remove-Variable -Name SMTPClient
# Requires that "Set-ExecutionPolicy RemoteSigned" has been set in Windows PowerShell
> powershell.exe C:\PATH\TO\windows-aws-ses-testmail.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment