S/MIME Part 2: Signed, Sealed, and Delivered through SparkPost
·
Dec 31, 2018
Key Takeaways
Premise: Part 2 moves from S/MIME theory to practice — demonstrating how to digitally sign and encrypt emails using SparkPost as the delivery platform.
Goal: Equip developers with a lightweight, command-line workflow to sign outgoing messages, verify signatures, and (optionally) encrypt content for specific recipients.
Highlights:
Setup: Install the open-source demo tools from GitHub (with automated Travis + pytest checks). The Pipfile handles all Python dependencies.
Sender keys:
Create a self-signed or CA-issued certificate (
.p12) for your email identity.Split it into private (
.pem) and public (.crt) files for use by the signing tool.
Signing:
Use the included
sparkpostSMIME.pyscript to sign test messages (e.g.,tests/declaration.eml).Confirm signatures visually in clients like Thunderbird (red dot icon).
Encryption:
Obtain each recipient’s public certificate (
.crt).Run the tool again to produce a signed + encrypted message.
Recipients can verify and decrypt using their private keys.
Delivery via SparkPost:
Configure a valid sending domain and API key.
Send messages through SparkPost’s API with tracking disabled to preserve integrity.
Bonus utility – mimeshow:
Displays human-readable RFC822 MIME structure for debugging or inspection.
Practical tips:
Keep filenames aligned with the From: address.
Avoid modifying message bodies after signing.
Use Bcc only for archival copies — those recipients can’t decrypt if the mail is encrypted to a single To address.
Q&A Highlights
Why use S/MIME signing?
It authenticates the sender and ensures message integrity — clients like Thunderbird show a visual indicator when the signature is valid.
How do I get my sender certificate?
Either self-sign via OpenSSL (for testing) or obtain a trusted certificate from providers such as Comodo (free for non-commercial use).
Can I encrypt messages for multiple recipients?
Only if you have each recipient’s public key. The demo script encrypts to the single To address by default.
What safeguards keep signatures from breaking in transit?
The tool sets SparkPost API options for transactional sending and disables open/click tracking, so the payload passes through unchanged.
What’s the role of mimeshow?
It parses raw email files and prints their multipart structure — useful for inspecting S/MIME signatures, attachments, and headers.
What’s next in the series?
Part 3 extends these S/MIME capabilities to on-premises secure email platforms such as PowerMTA and Momentum.

In part 1, we had a quick tour of S/MIME, looking at signing and encryption of our message streams across a range of mail clients. S/MIME messages can be signed (giving proof of sender’s identity), encrypted (keeping the message body secret), or both.

In this installment, we’ll:
Install some simple command-line tools for signing and encrypting email
Get your sender key / certificate for signing
Send a signed message via SparkPost, and look at the received message
Optionally, get your recipient certificate for encryption
Send a signed and encrypted message via SparkPost, and look at the received message
Try a handy standalone tool “mimeshow” to look at email file internals.
OK – let’s get started!
Bonus feature: displaying MIME parts with “mimeshow”
1. Install the tools
2. Get your sender key / certificate for signing
3. Send a signed message via SparkPost
4. Encrypting messages
Further thoughts & things to be aware of
This tool takes a super-simple approach to pulling in the necessary keys – it just looks for named files in the current directory. More complex arrangements, such as holding all keys in a database could easily be added, but I wanted the code to be as simple as possible.
You can include other recipients with Cc: and Bcc: and they will be delivered; this could be useful for archival purposes. Signed messages are received and can be displayed by other recipients complete with the signature. The tool strips the Bcc: header from the delivered message (like a desktop mail client would do).
To ensure that messages pass through SparkPost unchanged (which could break signing), the tool sets API options for “transactional” mailing, with open and click tracking disabled.
If you use encryption, bear in mind that the tool picks up the single To: address for that. The other recipients can decode the message body only if they have the To: recipient private key. If you’re just using secondary recipients as a record of deliveries made, for example, that may be OK anyway.
Signed, sealed delivered…I’m yours
That’s our quick overview of how to sign, seal, and deliver S/MIME messages through SparkPost. Quick reminder: the demo project is available on GitHub, and I’ve tried to make it easy to install and use.










