Part 1, Planning
Building a system to bulk import emails from your postmark server(s)

Search for a command to run...
Building a system to bulk import emails from your postmark server(s)

No comments yet. Be the first to comment.
In this series we will explore how to build a system to bulk manage Postmark e-mails from our command line. We will be able to: - Bulk import and export emails - Bulk test emails
[cover image: Photo by Maksim Goncharenok from Pexels] Goal As explained in part one, we want to import all Postmark templates into our local system to be able to change them in bulk and export them to Postmark later. In this section, we will look a...
Burning the world, at a discount, for code

It’s nine AM, my work begins, A clear direction, where to go, I concentrate, I take it all in, And so I start, without a stop. - It's ten AM, no time to breathe, A single focus, reach my goal, And so I write, it is a breeze, My laptop, me, we are one...
And yet, it's never wrong
At any given point there is only one most important thing you should be doing. Sadly, that seldom coincides with the most urgent. A solution to that is to carve a space dedicated to the important rather than the urgent. At Recovr we realized a few mo...
[Edit, 1st of September 2025: Philippe I'll pointed out to me that the artifacts I attribute to scrum have been addressed or removed in the latest scrum versions.] When you tell someone that you work in an agile team, or that you want to be more agil...
We use Postmark at Seraphin to handle our transactional e-mails.
We recently wanted to try and overhaul the way we work with our emails, but we have quite a few of them (a bit more than a hundred).
We wanted a tool to keep track of our changes, test them, and upload them easily.
This tool should be able to:
This article will explore the big picture of the project's initial considerations by discussing the strategy and our code's architecture.
When thinking of the overall strategy, we are interested in the big picture of how our project/product must behave. In our Postmark example:
Knowing this, we already have some choices and research to make. Does something already exist that will allow us to do these three tasks easily? (removing the need to do anything).
The answer to this is: kind of, mail mason will do some of what we want, namely testing and uploading. But it has a pretty big drawback IMO, and it would force us to change how our emails and files are structured. This does not preclude the use of this tool, but it does lead me to investigate further.
Can I quickly (more easily than changing how our emails are structured) make a tool to handle the three options? Is there some support for what I want to do? While answering this question, I saw: Postmark Api and Postmark Gem which suggested that it should not be too difficult to do.
So it looks like we can commit to building a quick tool, but how should it look or feel?
The tool will mainly be used by developers, so we probably can get away with a quick and dirty CLI. Knowing that my intended target uses ruby, I am pretty safe with a ruby program.
When thinking about the 'big picture' architecture of a project, even more one that is starting from scratch, here are the areas we will look for:
Here is something that should not shock you, but it probably will: A database can be composed of a folder with HTML files and a big yaml 'index' file. And you know how I know that? Because our project uses that as a Database. And I will expose to you now why it makes sense.
On the one hand, the HTML files need to be easily accessible by the people changing them. By having a template_name_template_id.html file per template, we manage to have. On the other, a lot of metadata (alias, layout, text_body, etc.) needs to be associated with a template. By having a metadata.yml file, we can associate that information with each template.
When working on something like this, I start with a very rough sketch of what I am trying to do. Usually, on the nice whiteboard I have in my office:

Yes, I know, my calligraphy might make it more of a challenge than it has to be for me.
Here is a good sketch of what the architecture of our project looks like (I made some changes compared to the rough sketch on the whiteboard while working on the project):

We will get into the details of these classes as we progress on the series, but the rough idea is:
We have two 'models' representing two different email types, which might be counterintuitive. You might say that there should be only an Email or Template class. But as I see it, these two classes are different and have different responsibilities:
As we will explore in later instalments, InternalTemplate represents the email in our internal DB. On the other hand, ExternalTemplate represents the template in Postmark. These are, in my opinion, different and should be conceptualized differently.
Moreover, the responsibility of InternalTemplate is to either send data to Postmark, whereas ExternalTemplate's responsibility is to receive data from Postmark.
The services are where the code to interact with Postmark is abstracted.
Planning is essential; even for a project that seems relatively trivial, I always take the time to create a rough sketch of what I am trying to accomplish.
This planning allows me to see where the problems might lie in the future and gives me an excellent foundation to work on when I start coding the particulars.
This does not mean that the plan is static, and I amend it throughout the course of a project.