Sending Templated Emails in SES
Amazon SES is a great tool for sending and receiving emails. The AWS
SES email templates work well and do the job. They're just hard to
use.
There's no official UI for editing and managing templates, and the
documentation is quite lacking. This guide should give you all the
information you need to get started sending beautiful emails.
Sending Templated Emails
1. Create a template in SES Templates
Step one is to design our template. You'll need to click the sign-up
button below and enter your AWS Keys. Once you've set up your account,
you will have an email template generated called
my-first-template
.
2. Check the Merge Data
This generated template has two slots for merge data (used by
Handlebars). These are called
companyName
and
name
. When we call the template from our code, we'll need to provide these
bits of information.
3. Call
sendEmail
The AWS api for sending template emails is
SESV2.sendEmail
. In JavaScript, it's called like so:
ses.sendEmail({
Destination: { ToAddresses: ['[email protected]'] },
FromEmailAddress: '[email protected]',
Content: {
Template: {
TemplateName: 'my-first-template',
TemplateData: JSON.stringify({
name: 'Joe Bloggs',
companyName: 'Acme Inc.'
})
}
}
}, callback);
Got any questions?
It's pretty simple stuff, but we might have missed something. Feel free to get in touch and ask any questions you still have.
Get help writing emails
Coding emails sucks, join our community of email developer, designers, and
managers to get help on the annoying edge-cases.
Join the Community