Today, we’re super excited to announce that Postmark now has an official command-line interface 🎉. We built a proof of concept earlier this year during our company-wide hack week, and now it’s available for everyone!
Version 1.0.0 supports pushing and pulling templates, sending emails, and fetching server lists, all from the command-line. This makes Postmark and your CI/CD pipeline go together like peas and carrots.
From the command line, run:
npm i postmark-cli -g
Once npm does its thing, run the
postmark command and you will see some high-level usage details. You’re all set!
Protip: You’ll be asked to authenticate by entering your server or account token each time you run a command. If you prefer, you can bypass this step by supplying tokens as environment variables.
Push and pull email templates #
Have you gone to bed at night dreaming of a time where you could store email templates in git and automate the deployment process? Dream no more!
Start by downloading your templates from Postmark using the
templates pull command, followed by the path of where you want to save your templates:
postmark templates pull ~/my-templates
The directory structure will look a little something like this:
my-templates ├── password_reset │ ├── content.html │ ├── content.txt │ └── meta.json └── welcome ├── content.html └── meta.json
Each template gets its own subdirectory that contains the HTML and text versions, along with some metadata containing the name, subject, and alias. From here, you’re free to code up some HTML like it’s 1995... or go ahead and commit to your git repository. Up to you.
When you’re ready to push your templates to Postmark, use the
templates push command, followed by the template path:
postmark templates push ~/my-templates
Before the templates get pushed, you’ll see a summary of changes. You can see whether a template will be modified or newly added to the server. If you’ve pushed templates in the UI, this might look a little familiar. Confirm your changes by typing
y and hitting
There you have it! Your templates are now up on Postmark. If automation is your thing, you can even use a CI/CD tool like Travis CI or CircleCI to trigger pushes from git commits. More details about the templates command are up on our wiki.
Send emails #
Our CLI tool also supports email sending. You might find this useful for triggering email notifications as part of a build process. I, however, use it for emailing my grandma:
postmark email raw --from="firstname.lastname@example.org" --to="email@example.com" --subject="Hi Grandma" --html="<marquee>Want to grab ice cream later?🍦</marquee>"
email raw command works similarly to our public email API endpoint, where the HTML and text content gets passed along with every request. We even support templated emails as well. Check out the wiki for more details.
Fetch server lists #
Now you can quickly see a list of Postmark servers on your account, jump to the server dashboard from your web browser, or grab tokens for development.
postmark servers list and authenticate with your account token:
Server tokens are masked by default just to be safe. You can show the tokens by passing in the
--show-tokens flag. Tread with caution though, this means your server tokens will appear in your command-line history. Be sure to check out the wiki for more nifty tricks.
That’s a wrap! #
🛸TOP SECRET TIP: Run
postmark cheats if you’re feeling up to it.