Getting Self-Hosted Mail to Actually Deliver
Notes from a bulk-mail server I built for a client, with fourteen sending IPs. The setup that has to be right, the config, and why a first send that passed every check still went to spam.

Self-hosted mail has a reputation for being impossible. Mostly it's just unforgiving. The last mail server I built was for a client: one dedicated box running Proxmox, a routed /28 on top of the main IP, and fourteen sending addresses, each with its own Postfix transport. Most of what can go wrong is on a short list you can check before sending a single real message. The one thing you can't check that way is the part that bit hardest.
Ask about port 25 first
Most hosts block outbound port 25 on new accounts, because most people asking for it are spammers. This one did too. The ticket went in on day one and sat in the host's review queue for a while, so I proved the rest without it. I injected test messages from three of the senders and ran a packet capture on the way out. Each connection left from the right source IP and then retransmitted into the block, which is all I needed for that step.
If I'd built everything first and only found out at the end, that wait would have landed right at the end of the job, where it hurts most.
One transport per address
Each sender gets its own outbound IP. Postfix does that with a map from sender to transport, and a transport per IP in master.cf:
textout-s1 unix - - n - - smtp -o smtp_bind_address=203.0.113.97 out-s2 unix - - n - - smtp -o smtp_bind_address=203.0.113.98
texts1@example.com out-s1: s2@example.com out-s2:
with sender_dependent_default_transport_maps pointing at the second file. Mail from s5@ leaves from the fifth address, and nothing else on the box needs to know.
Reverse DNS on every address
The receiving server looks up the IP your mail came from, expects a name back, and expects that name to point at the same IP. Miss one address in the pool and a slice of your mail looks suspicious for no obvious reason. Here that was fourteen PTR records, set through the host's API, and I checked the full circle for every one of them rather than the first:
bashfor i in $(seq 1 14); do ip="203.0.113.$((96 + i))" ptr=$(dig +short -x "$ip") fwd=$(dig +short "${ptr%.}") [ "$fwd" = "$ip" ] && echo "s$i ok $ip -> $ptr" || echo "s$i FAIL $ip -> $ptr -> $fwd" done
SPF, DKIM, then DMARC
textexample.com. TXT "v=spf1 ip4:203.0.113.96/28 -all" m2i._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..." _dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:reports@example.com"
SPF says which addresses may send. DKIM signs each message (opendkim as a milter, 2048-bit key) so the receiver can tell nothing changed on the way. DMARC tells the receiver what to do when those disagree, and more usefully, asks it to send you reports. I start at p=none and read the reports before tightening anything. Going straight to reject is how people find out their invoicing system was sending as the domain too.
A small one I won't forget: I sent the DKIM and DMARC values to the client in a chat window, and the chat turned the equals sign and capital D in v=DKIM1 into a grinning emoji. Since then DNS records go over as a text file, never pasted into a message.
Then Gmail put it in spam anyway

Once the port opened, the first real send got a 250 OK from Gmail with SPF, DKIM and DMARC all passing. Then it went to spam. Nothing was misconfigured. A new IP on a new domain has no history, and authentication only proves who you are, not that anyone wants your mail.
That's why I never promise inbox placement on fresh infrastructure. Reputation comes from sending small amounts to people who actually open it and growing over weeks. Keep bounces low and honour unsubscribes straight away, because complaints are the number that hurts most.
Write the runbook
The build shipped with an admin runbook: the order things get deployed in, how to add a sending tenant, how backups run and how to restore one, the security setup, and the exact steps for the day port 25 opened. I'd run the restore myself before writing it down. Without that, I'd have built something only I can operate, and that's a dependency for the client, not a system.