This library allows you to publish your emails to SparkPost automatically. No longer you need to copy paste your emails to SparkPost and mistakenly update the wrong template. A version controlled single source of truth for your emails.
Made for Foundation for Emails but can be used for other frameworks such as MJML.
The library works by mapping your generated email files to a SparkPost template
using a JSON file called
sparkpost-map.json. It is also possible to specify
the name and path of the file.
The keys of the root object are the IDs of the templates in SparkPost. If the ID does not exist, the template will be created.
config key contains the configuration used by this library.
This config object means the following:
content.htmlwith the contents of the file found at
content.email_rfc822with the contents of the file found at
content.textwith the contents of the file found at
While you can use both html and text if desired, you cannot mix either of them with email_rfc822.
config.content object is essentially merged into the
object after the source files are read.
sparkpost key contains any template configuration you would like to
specify. This allows you to version control name, description and other options
of your templates. Add any configuration as described in
Do NOT specify the
published field or any readonly fields as this will cause
Publish all your emails using the
spp publish --api-key your-api-key-here
command. Optionally, you can specify that you only wish to publish one email
--template template-id flag. New templates will be created and
Multiple environments, review/staging
If you have multiple environments you can use the
suffix flag to deploy your
templates with a suffix.
--suffix review with template
password-reset will create or
update a template with the ID of
Submit your drafts using the
spp draft command with the same options as the
-v flag for more verbosity. Helpful to identify any errors.
The SparkPost API key needs the following permissions:
- Templates: Read/Write