Stop Letting Shared Hosting Kill Your Email Deliverability
It happens every Tuesday. A client calls, screaming that their urgent invoice to a partner in Bergen bounced. Why? Because some script kiddie on the same shared IP address decided to blast out a million pharmacy spam emails, landing the whole subnet on the Spamhaus Block List (SBL).
If you are serious about infrastructure, you don't share your mail IP. You own it.
Running your own mail server used to be a nightmare of open relays and Sendmail configuration files that looked like line noise. But with Postfix and a modern Linux distribution like CentOS 6 or Debian Squeeze, it is manageable. More importantly, it gives you total control over your logs, which is vital for compliance with Norway's Personopplysningsloven.
Here is how we build a rock-solid mail relay that actually delivers.
The Prerequisite: It Starts with the Network
Before you even touch yum install, you need to verify your environment. Mail servers live and die by their reputation.
- Clean IP Address: You need a dedicated IP that isn't already blacklisted.
- Reverse DNS (PTR) Record: This is non-negotiable. If your forward DNS (
mail.example.no) points to1.2.3.4, then1.2.3.4must resolve back tomail.example.no.
Pro Tip: Most budget VPS providers make you open a support ticket to change your PTR record, which takes days. On CoolVDS, we give you full control over rDNS in the client panel. You can spin up a node and set the PTR record in under 60 seconds. No waiting on support.
Step 1: Installation and Basic Setup
We will stick to CentOS 6 for this guide due to its long-term stability in enterprise environments. First, remove Sendmail (if present) and grab Postfix.
yum remove sendmail
yum install postfix
Once installed, we need to make it the default MTA (Mail Transfer Agent).
alternatives --config mta
Select Postfix from the list.
Step 2: The main.cf Configuration
Open /etc/postfix/main.cf. This is the brain of your operation. Do not use the defaults. They are too permissive.
We need to set the hostname and domain explicitly to match your FQDN (Fully Qualified Domain Name).
myhostname = mail.yourdomain.no
mydomain = yourdomain.no
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
The "Trusted Networks" Trap
Be very careful with the mynetworks setting. If you set this to 0.0.0.0/0, you become an open relay. Spammers will find you in minutes. Literally minutes.
mynetworks = 127.0.0.0/8
Step 3: Fighting Spam and The "Oslo Lag"
Latency matters. When your server is shaking hands with another mail server, every millisecond of I/O wait counts. If your disk is thrashing because of "noisy neighbors" on a cheap VPS, the connection might time out during the heavy spam checks.
Add these restrictions to main.cf to filter garbage before it hits your queue:
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
reject_rbl_client zen.spamhaus.org,
reject_rbl_client bl.spamcop.net
This checks the incoming IP against Spamhaus and SpamCop. It effectively blocks about 90% of junk without your CPU lifting a finger.
Step 4: Storage Performance and Data Integrity
Mail servers are I/O intensive. A busy Postfix queue generates thousands of tiny writes. On a traditional 7.2k RPM SATA drive, this is a bottleneck. The server load shoots up, and mail delivery crawls.
This is where hardware choice becomes critical. You have two options:
| Storage Type | Read/Write Speed | Suitability |
|---|---|---|
| Standard SATA | ~100 MB/s | Fine for backups, terrible for active Maildirs. |
| Enterprise SSD (CoolVDS) | ~500 MB/s+ | Essential for high-volume transactional email. |
At CoolVDS, we have moved our primary clusters to Enterprise SSDs (Solid State Drives). The difference in parsing a 10GB mail log or processing a queue of 50,000 newsletters is night and day. Don't let disk I/O kill your SEO or your reputation.
Step 5: Compliance and "Datatilsynet"
Hosting in Norway brings specific advantages and responsibilities. Under the Data Protection Directive, you must ensure that personal data (which includes email addresses) is secure.
Using a US-based host puts you in a grey area regarding the Patriot Act. By hosting on a VPS in Norway, your data stays within the jurisdiction of the EEA and Norwegian law. Ensure your logs are rotated correctly to comply with retention policies:
# /etc/logrotate.conf verification
/var/log/maillog {
weekly
rotate 4
compress
}
Final Thoughts
Running a mail server isn't for the faint of heart. It requires vigilance. But the reward is privacy, speed, and reliability that Google Apps or Hotmail simply cannot offer you.
If you are ready to build a system that respects your technical skills, stop fighting with sluggish hardware. Deploy a CentOS instance on CoolVDS today. We offer the low latency to NIX (Norwegian Internet Exchange) and the raw SSD power your Postfix queue demands.