Testing SES with PowerShell


Testing SES with PowerShell

SES, simple email service is one of the many services provided by Amazons AWS. It is exactly as advertised a simple email system that one can use to relay mail through. You can't set up an email box so there is no receiving mail with SES. It is used in a lot of different situations, one that we often find it used for is sending from forms on a site. Often with one plugin or another or with a snippet of code. With either method, there are times when it just goes wrong and you need a way to test. If that is where you're at here are some solutions for you to test ses.

To run the test we mention below you will need to have SES set up in your AWS account. If you have not done this yet you will have to add your domain and verify it via DNS records as well as verify an email address. Then you will need to create your SMTP credentials while doing this make sure you save the info as this is the only time you can get it.  When you have completed these task you can begin using SES.

If you're on a windows platform you can use the following line in the form of a PowerShell script. Copy the text below into your text editor and save it as a .ps1 file then run it from PowerShell. Of course, you will need to add your own from, to, subject, and keys.

Send-MailMessage -From <from> -to <to> -subject <subject> -SmtpServer email-smtp.us-east-1.amazonaws.com -Credential $(New-Object System.Management.Automation.PSCredential -argumentlist <AWS_ACCESS_KEY>, $(ConvertTo-SecureString -AsPlainText -String <AWS_SECRET_KEY> -Force)) -UseSsl -Port 587
As always if you run into issues using SES or any other AWS product we are here to help and provide a solution to the issue at hand.

Please see our Disclaimer before using any code found on this site.
No Comments

Sorry, the comment form is closed at this time.