Bulletproof Postfix: Surviving the Spam Wars
Let’s be honest: nobody wants to manage a mail server today. It is the sysadmin’s graveyard. You spend three hours configuring users, and then six months fighting to get your IP off a blacklist because one marketing intern decided to send 5,000 emails to a purchased list using a PHP script.
But here we are. You need it. Maybe for privacy, maybe to avoid the per-user costs of hosted solutions, or maybe because the Personopplysningsloven (Norwegian Personal Data Act) demands your data stays on Norwegian soil. If you are going to host email in 2010, you cannot afford to be casual about it. The spammers are winning, and an insecure Postfix installation is just a free resource for them.
I’ve seen servers melt under the load of dictionary attacks. I’ve seen mail queues lock up entire file systems because of I/O wait. Here is how we build a Postfix server that actually stays up, keeps your IP clean, and handles the load.
The Architecture of Trust (and I/O)
Before we touch a config file, let’s talk iron. Email is deceptive. It looks like small text files, but it is actually a brutal I/O punisher. When you have 500 incoming connections, SpamAssassin scanning content, ClamAV checking attachments, and logs writing to disk—your hard drive seek times are the bottleneck.
Pro Tip: Do not run a production mail server on a cheap, oversold VPS. If youriowaitspikes above 10%, your mail queue stalls. At CoolVDS, we use enterprise SAS RAID-10 arrays specifically to handle the random write patterns of/var/spool/postfix. Latency kills mail delivery speed just as much as bandwidth.
Step 1: The Fortress Configuration
We are using CentOS 5.4 for this setup, though the principles apply to Debian Lenny. The goal is to reject bad mail before it hits your queue. This saves CPU and disk I/O.
Open your /etc/postfix/main.cf. If you are using the defaults, you are wrong.
# The Basics
myhostname = mail.yourdomain.no
myorigin = /etc/mailname
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
# The Gatekeeper
# Note: In Postfix 2.6/2.7, we rely heavily on recipient_restrictions
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
reject_invalid_hostname,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_unknown_sender_domain,
reject_rbl_client zen.spamhaus.org,
reject_rbl_client bl.spamcop.net
The Critical Detail: Notice the RBLs (Real-time Blackhole Lists) at the end. zen.spamhaus.org is your best friend. It blocks known spammers and dynamic residential IP ranges effectively. By rejecting them here, during the SMTP handshake, you save your server from processing junk.
Step 2: Authentication & Encryption
Cleartext auth is a death sentence. You need TLS. In 2010, there is no excuse for sending passwords over the wire in plain text, especially if your dev team is connecting from a coffee shop in Oslo.
smtpd_tls_security_level = may
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/mail.pem
smtpd_tls_key_file = /etc/pki/tls/private/mail.key
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
We are handing off authentication to Dovecot here. It’s cleaner than running saslauthd separately. It simplifies the stack.
Step 3: The Norwegian Context (Latency & Law)
Why host this in Norway? Aside from the Datatilsynet ensuring strict privacy oversight, latency matters. If your users are in Scandinavia, routing mail through a server in Texas adds unnecessary hops.
Connecting to the NIX (Norwegian Internet Exchange) ensures that local traffic stays local. When we provision a VPS Norway instance at CoolVDS, we ensure the routing table is optimized for Nordic peers. That means when your CEO sends an email to a client in Bergen, it doesn't cross the Atlantic twice.
Step 4: Preventing the "Blacklist Blues"
You configured the server perfectly. But can the world trust you? You need SPF and DKIM.
- SPF (Sender Policy Framework): Add a TXT record to your DNS.
v=spf1 mx a ip4:80.xx.xx.xx -all. This tells the world: "Only this IP sends mail for me." - DKIM (DomainKeys Identified Mail): Install
dkim-milterfrom the EPEL repo. It cryptographically signs every outgoing email. Hotmail and Gmail look for this signature. Without it, you are likely to land in the Junk folder.
The "Clean IP" Imperative
This is the dirty secret of hosting. You can have the best config in the world, but if your hosting provider gave you an IP address that was used by a spammer last week, you are doomed. You will spend months fighting Return Path and Spamhaus.
This is where managed hosting differs from the bargain bin. At CoolVDS, we scrub our IP pools. We don't recycle IPs immediately. When you spin up a server, you get a reputation-neutral address. We also provide basic ddos protection at the edge, because port 25 is a favorite target for botnets trying to brute-force relays.
Final Thoughts
Running a mail server in 2010 requires vigilance. You need to tail your logs (tail -f /var/log/maillog) and watch for anomalies. You need fast disk I/O to handle the queues during peak hours. And you need a hosting partner that understands that an IP address is a reputation, not just a number.
Don't let a sluggish server or a dirty IP destroy your deliverability. If you are ready for a setup that respects your uptime and your data privacy, it’s time to upgrade.
Deploy a high-performance Postfix instance on CoolVDS today. Low latency, clean IPs, and rock-solid storage.