S/MIME Part 3: Plug and Play for On-Premises Secure Email
·
Dec 1, 2019
Key Takeaways
S/MIME integration for on-premises MTAs: learn how to inject signed and encrypted email streams into PowerMTA, Momentum, or SparkPost SMTP while preserving existing DKIM and compliance setups.
Hybrid security model: combine S/MIME encryption + DKIM signing to guarantee both message authenticity and content privacy in regulated environments.
Deployment flow: configure environment variables (SMTP_HOST, credentials, keys), run the --sign --encrypt --send_smtp workflow, and validate delivery reports.
Performance insight: tests show near-identical speed for SMTP vs API injection (~60 ms per message, 200–280 ms for larger files).
Security best practices: store private keys and API passwords in restricted files (chmod 0700), use STARTTLS and authenticated SMTP sessions.
Use cases: enterprises modernizing legacy mail systems can extend encryption end-to-end without abandoning existing infrastructure.
Q&A Highlights
Why adapt S/MIME for on-prem servers instead of cloud APIs?
Many regulated industries (bank and healthcare sectors) must retain mail on-site. This approach keeps control over message flow while adding modern cryptographic protection.
How does SMTP injection work with PowerMTA or Momentum?
You inject fully formed S/MIME messages to the local listener (port 25 or private VLAN). These MTAs then handle DKIM signing and delivery as usual.
Is S/MIME compatible with DKIM?
Yes — DKIM signs the message after S/MIME encryption, so authentication and integrity checks remain intact.
How do I protect my SMTP credentials and keys?
Export environment variables only in locked-down scripts and use file permissions to restrict access to yourself (
chmod 0700 my_envs.sh).What should I monitor after setup?
Delivery latency (API vs SMTP), TLS handshake success rate, DKIM/S-MIME validation results, and error logs for “relaying denied” or missing auth.
Who benefits most from this configuration?
Organizations running self-hosted mail gateways that require compliance-grade encryption yet want plug-and-play tooling without rewriting mail pipelines.

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. For organizations implementing S/MIME encryption, understanding how to collect recipient public keys efficiently becomes crucial for scalable secure email operations. Part 2 took us through a simple command-line tool to sign and encrypt emails, then send them through SparkPost.
In this part, we’ll look at how the tool can be adapted to inject mail streams into on-premises platforms such as Port25 PowerMTA and Momentum.
OK – let’s get started!
1. Getting Started
Installing the tool, getting your keys etc. is exactly the same as before. When you’re using an on-premises email system such as PowerMTA or Momentum, you’re already responsible for setting up sending domains, DKIM keys etc. Organizations running on-premises systems also often need to address email archiving system challenges for regulatory compliance and data retention requirements. What we need to do now, is to provide some way of injecting the fully-formed S/MIME messages into your servers.






