Dominic Böttger

← Back to blog

Published on March 31, 2020 by Dominic Böttger · 2 min read

There is a lot of documentation and examples for the Amazon Web Services cli tools but there are less examples for the AWS PowerShell module. I had the problem that I did not find a working example to send emails via AWS SES and had to find a solution by myself. I hope the following post will save your time.

I assume that you already have the PowerShell tools installed and your AWS credentials have been set up.

As I already had the AWS cli installed my credentials were already stored and I just had to install and load the PowerShell module.

Install-Module -Name AWSPowerShell.NetCore
Import-Module AWSPowerShell.NetCore

If you need to install it differently or further information on how to set up the credentials you should have a look at the official AWS PowerShell tools documentation

Creating and storing the template

First, I created a json file for the template and saved the contents below as mytemplate.json.

{
  "Template": {
    "TemplateName": "MyTemplate",
    "SubjectPart": "Greetings, TESTSTRING!",
    "HtmlPart": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /> <title>Demystifying Email Design</title> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/> </head> <body>Español üäü {{name}}</body> </html>",
    "TextPart": "Dear TESTSTRING,\r\nYour favorite animal is TESTSTRING."
  }
}

To load the template into the SES template store the content of the json needs to be loaded (Unicode is important! ), converted from json to an object and then piped to the New-SesTemplate CmdLet.

Get-Content -Path ./mytemplate.json -Encoding UTF-8 | convertFrom-Json | New-SesTemplate

Sending the mail

After the template has been created you are able to send mails with the content of the template and fill the placeholders in the template with data.

For this you should save the contents below in a file named myemail.json.

{
  "Source":"Mary Major <mary.major@example.com>",
  "Template": "MyTemplate",
  "Destination_ToAddress": [ "test@example.com" ],
  "TemplateData": "{ \"name\":\"Español\", \"favoriteanimal\": \"alligator in IL template\" }"
}

The json needs to be adjusted to fulfill your needs. Which means especially the mail addresses should be replaced to align with your SES and domain configuration.

To send the mail you just need to execute the code below.

Get-Content -Path ../myemail.json -Encoding UTF-8 | convertFrom-JSON | Send-SESTemplatedEmail

Congratulations for delivering your email via SES with PowerShell!

Written by Dominic Böttger

← Back to blog
  • Syncing SharePoint and OneDrive on Arch Linux with One Click

    Syncing SharePoint and OneDrive on Arch Linux with One Click

    Set up Microsoft SharePoint and OneDrive sync on Arch Linux using abraunegg/onedrive. Includes a protocol handler script that makes the "Sync" button in SharePoint work natively, with automatic drive detection and systemd background sync.

  • From Sequential to Parallel: Adding Agent Teams to Spec Kit

    From Sequential to Parallel: Adding Agent Teams to Spec Kit

    How we extended Spec Kit with a new /speckit.team-implement command that auto-detects parallel work streams from your task list and spawns specialized AI agent teams to implement features simultaneously -- complete source code, algorithm walkthrough, and usage guide.

  • Building a Private Claude Code Plugin Marketplace for Your Team

    Building a Private Claude Code Plugin Marketplace for Your Team

    Learn how to structure a private Claude Code plugin marketplace for your team, including repository layout, naming conventions, and how to register local or remote marketplaces.

  • Spec Kit + Ralph Loop: Solving AI Context Exhaustion in Large Features

    Spec Kit + Ralph Loop: Solving AI Context Exhaustion in Large Features

    How we combined Spec Kit's structured planning with Ralph Wiggum's fresh context methodology to build an AI-powered development loop that can implement features of any size without context pollution.

  • Mistral Releases Vibe CLI and Devstral 2: Open-Source AI Coding Goes Next Level

    Mistral Releases Vibe CLI and Devstral 2: Open-Source AI Coding Goes Next Level

    Mistral AI launches Vibe CLI and Devstral 2, bringing powerful open-source AI coding assistance to your terminal. Learn how to install and get started with these game-changing tools.

  • Auto Dark Mode on Linux Based on Real Sunrise and Sunset

    Auto Dark Mode on Linux Based on Real Sunrise and Sunset

    Set up automatic theme switching on Linux that follows the real sunrise and sunset times for your location, not just fixed schedules. Complete guide for Hyprland/Omarchy with systemd timers.