Build beautiful emails quickly with Dyspatch and send them to your customers using Amazon's Simple Email Service.
Once your email has been reviewed and approved by your team's stakeholder, you can now export your email using the Download/Export button.
You will need to select the HTML/Handlebars option to be compatible with SES's templating system.
A zipped file will be downloaded onto your system with the HTML, plain text content, metadata, and localizations (if applicable).
SES emails are created through the AWS API. We recommend setting up an API integration with Dyspatch so your emails can always be in sync.
You can also use AWS's API directly to create emails. The script below assumes you have jq installed and the AWS CLI tool correctly set up.
First, save the below script as "upload.sh"
#!/usr/bin/env sh
DIR="/tmp/template"
# Extract the template to /tmp/template
unzip "$1" -d $DIR
# Set up variables
file="`ls $DIR/*.html`"
html_file="${file##*/}"
template_name="${html_file%%.*}"
metadata_file="$template_name-metadata.txt"
# Escape Name
ses_template_name="`echo $template_name | sed -Ee 's/[[:blank:]]+/_/g'`"
# Test for optional txt file
if test -f "$DIR/$template_name.txt"; then
txt_file="$template_name.txt"
txt_content="`cat $DIR/$txt_file`"
else
txt_content=""
fi
# Get subject line
subject="`cat \"$DIR/$metadata_file\" | grep 'Subject:' | awk '{sub($1 FS, ""); print}'`"
# Get template content
html_content="`cat \"$DIR/$html_file\"`"
# Construct the JSON object
jq --null-input\
--arg html "$html_content"\
--arg txt "$txt_content"\
--arg subject "$subject"\
--arg name "$ses_template_name"\
'{"Template": {"TemplateName": $name, "SubjectPart": $subject, "HtmlPart": $html, "TextPart": $txt}}'\
> $DIR/template.json
# Upload to AWS
aws ses create-template --cli-input-json file://$DIR/template.json
echo "Uploaded template: '$template_name'"
Then, make the script executable
$ chmod +x upload.sh
Now you can upload the Dyspatch email in the zip file you downloaded. Make
sure to replace [Dyspatch Template Name]
with the actual file name!
$ ./upload.sh "[Dyspatch Template Name].zip"
Verify that the email was uploaded by going to SES > Email Templates.
You're done! Your email is now ready to send through SES.