Operations

Set up a VPS for running an email marketing system

The first mistake most people make when they move email marketing to a VPS for running an email marketing system is thinking the hard part is sending. It is not. Sending is easy. The hard part is landing in the inbox, not the spam folder, and doing it at scale without getting your IP blacklisted. On a shared hosting account you cannot fix deliverability because you share the IP with strangers. On a Linux VPS you own the IP, the rDNS, the mail server, and the reputation. This guide walks through the full stack: the mail transfer agent, authentication records, sending IP warm-up, and the monitoring that keeps your sender score healthy.

Prerequisites

  • A Linux VPS running Ubuntu 24.04 LTS or Debian 12, with a dedicated IPv4 address. Email deliverability depends on a stable IP you control.
  • Root access over SSH. Every command in this guide assumes you are root or have full sudo privileges.
  • A domain name you control, with DNS management access so you can add TXT records.
  • Port 25, 465, and 587 open outbound. Some providers block port 25 by default, so confirm yours allows SMTP traffic.

Why a dedicated IP matters for email marketing

Email providers judge your messages by the reputation of the IP address they come from. On shared hosting, you might be the only legitimate sender on an IP that a spam campaign ruined yesterday. That is why a VPS for running an email marketing system needs a SMTP VPS with a clean IP, so your sender reputation starts neutral and stays under your control. The rDNS record, the volume you send, and your bounce handling all feed into that reputation.

You also want the option to scale. A small campaign list of a few thousand subscribers runs fine on a 2GB RAM VPS. A serious volume of tens of thousands of messages a day wants 4GB or 8GB, because the mail queue plus logging plus a statistics database all consume memory at once. Start small, verify deliverability, then grow the plan.

Architecture of a self-managed email stack

Run a separate VPS for sending only if your budget allows. Never mix your transactional mail from your application with bulk marketing campaigns on the same IP. A spike in marketing volume can drag down the reputation of your password resets and invoices. If you must use one server, keep two Postfix instances on separate IPs, or use separate subdomains with their own authentication records, for example mail.yourdomain.com for transactional and news.yourdomain.com for campaigns.

Your stack has four layers:

  • The mail transfer agent: Postfix, which handles SMTP delivery.
  • Authentication: SPF, DKIM, and DMARC records that prove you are who claims to be.
  • Reverse DNS: the PTR record that ties your IP back to your domain.
  • Tracking and analytics: a tool that logs opens, clicks, bounces, and unsubscribes.

For the tracking layer you can use an open-source platform like Mautic or Keap alternatives, or a lightweight tool like Listmonk. This guide focuses on the mail server and authentication, which most tutorials skip in favor of installation steps.

Step 1 - Install and configure Postfix

Start with the mail transfer agent. Postfix is the default MTA on most Linux distributions and it handles high volume well. On Ubuntu 24.04 or Debian 12, install it with:

sudo apt update
sudo apt install postfix postfix-mysql mailutils

During installation, choose Internet Site and enter your sending domain when prompted. The postfix-mysql package is optional unless you plan to store mail users in a database, but mailutils gives you mail and mailq for testing.

Edit the main configuration to set your hostname and restrict relaying:

sudo nano /etc/postfix/main.cf

Make sure these lines exist:

myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 127.0.0.0/8
home_mailbox = mail/

Restart Postfix and verify it is running:

sudo systemctl restart postfix
sudo systemctl status postfix

The expected output is a status of active (running). Test the server locally by sending a message to your own address:

echo "Test message" | mail -s "Postfix test" [email protected]

Step 2 - Set up SPF, DKIM, and DMARC

Authentication records decide whether receiving servers trust you. Without all three, your messages go to spam or get rejected outright. Configure them in order because each one builds on the previous.

First, the Sender Policy Framework (SPF) record. This TXT record lists which IP addresses are allowed to send mail for your domain. Add this to your DNS zone:

yourdomain.com.  TXT  "v=spf1 ip4:YOUR_VPS_IP include:_spf.google.com ~all"

Replace YOUR_VPS_IP with your actual IPv4 address. The ~all at the end tells receiving servers to soft-fail messages from unlisted IPs, which is safer for testing than the hard -all.

Next, DomainKeys Identified Mail (DKIM). Install OpenDKIM and generate a key pair:

sudo apt install opendkim opendkim-tools
sudo mkdir -p /etc/opendkim/keys/yourdomain.com
sudo opendkim-genkey -D /etc/opendkim/keys/yourdomain.com/ -d yourdomain.com -s mail
sudo chown -R opendkim:opendkim /etc/opendkim/keys/

Edit /etc/opendkim.conf and enable these lines:

Mode                sv
SubDomains          no
AutoRestart         yes
Canonicalization    relaxed/simple
KeyFile             /etc/opendkim/keys/yourdomain.com/mail.private
Selector            mail
Socket              inet:8891@localhost

Add the public key from the mail.txt file as a TXT record in DNS with the name mail._domainkey. It looks like this:

mail._domainkey.yourdomain.com.  TXT  "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ..."

Finally, DMARC, which tells receivers what to do with mail that fails SPF or DKIM. Start with a monitoring policy before enforcing:

_dmarc.yourdomain.com.  TXT  "v=DMARC1; p=none; rua=mailto:[email protected]"

After a week of clean results, change p=none to p=quarantine, then to p=reject once you are confident.

Verify all three records resolve correctly with:

dig TXT yourdomain.com +short
dig TXT mail._domainkey.yourdomain.com +short
dig TXT _dmarc.yourdomain.com +short

Step 3 - Configure rDNS and clean the IP

Reverse DNS is the PTR record that maps your IP back to a hostname. Most providers let you set this in the control panel, and thueVPS includes free rDNS on its dedicated servers. Set the PTR record to mail.yourdomain.com so it matches the hostname in your Postfix configuration.

Before you start sending, check whether your IP is already on any blacklists. A new IP might carry baggage from a previous owner:

dig -x YOUR_VPS_IP +short
curl -s "https://api.hackertarget.com/reverseiplookup/?q=YOUR_VPS_IP"

Check major blocklists manually at mxtoolbox.com or use a script that queries Spamhaus, Barracuda, and SpamCop. If your IP is listed, open a ticket with the blocklist operator and request delisting, providing proof you own the IP and plan to run a legitimate newsletter service.

Step 4 - Warm up the sending IP and batch your mail

Do not send 50,000 emails on day one from a fresh IP. Receivers treat sudden volume spikes as spam behavior. The realistic schedule starts at a few hundred messages per day and doubles every few days. Over four weeks you reach steady state without tripping spam filters.

Postfix handles bulk sending poorly if you fire everything at once. It opens many simultaneous connections, which looks suspicious. Limit the connection rate and concurrency in /etc/postfix/main.cf:

smtp_destination_rate_delay = 1s
smtp_destination_recipient_limit = 50
default_destination_concurrency_limit = 5

These settings spread delivery over time, which mimics human behavior and keeps you under the radar. The trade-off is slower throughput, but for a newsletter that is acceptable. If you need true high volume, run multiple MTAs across several IPs and rotate the sender reputation load.

Step 5 - Track opens, clicks, and bounces

A VPS for running an email marketing system is only useful if you can measure the campaign. Install Listmonk, a self-hosted newsletter manager that handles subscribers, templates, and campaign analytics:

docker run -d --name listmonk-db -e POSTGRES_PASSWORD=listmonk -v listmonk-data:/var/lib/postgresql/data postgres:16
docker run -d --name listmonk -p 9000:9000 listmonk/listmonk:latest

Visit http://YOUR_VPS_IP:9000, log in with the default credentials, and connect it to your SMTP server. Listmonk adds tracking pixels and link rewrites automatically. More importantly, it processes bounces from the Postfix log and removes invalid addresses, which keeps your list quality high and your bounce rate below the 2% threshold that gets you flagged.

Troubleshooting common email issues

If your messages land in spam, work through these checks in order:

  • Confirm SPF, DKIM, and DMARC all pass. Use mail-tester.com for a free detailed report on a test send.
  • Verify the rDNS matches your sending hostname. A mismatch is an instant spam flag.
  • Check your IP against Spamhaus at https://check.spamhaus.org.
  • Review the Postfix logs for delivery errors:
sudo journalctl -u postfix | grep -i "reject\|bounce\|error" --last 100

The most common failure is a missing or malformed DKIM selector. Double-check the DNS TXT record name matches the selector set in opendkim.conf.

Scale and pricing considerations

You do not need an expensive plan to start. A 2GB RAM VPS handles a few thousand subscribers comfortably, and a 4GB plan covers most growing newsletters. thueVPS offers monthly billing VPS plans with no long-term contract, which matters when you are still testing volume and IP reputation. The cost is predictable, and you can upgrade the plan without migrating servers.

As your list grows past tens of thousands of recipients, revisit the architecture. At that point you want a dedicated SMTP VPS with multiple IPs, or a dedicated server if you also run the web application and the database in the same place. The principle stays the same: control the IP reputation, authenticate everything, and measure every campaign.

FAQ

Can I run email marketing on a shared hosting account?

Technically yes, but deliverability will suffer because you share the IP with unknown senders. A VPS gives you a dedicated IPv4, full control over rDNS and authentication records, and a clean starting reputation. That is the difference between a campaign that lands in inboxes and one that dies in spam.

How much RAM does a VPS need for email marketing?

A 2GB RAM VPS handles a few thousand subscribers with Postfix, OpenDKIM, and a tracking tool comfortably. For lists of tens of thousands, move to 4GB or 8GB because the queue, logs, and database compete for memory during a send. Start small and upgrade when the metrics say you need it.

Why does my email keep going to spam even with SPF and DKIM?

Check three things: the rDNS record must match your sending hostname, your IP must not be on a blacklist, and your sending volume must ramp up gradually. A fresh IP that suddenly sends thousands of messages triggers spam filters regardless of authentication. Use a tool like mail-tester.com to see the full score breakdown.

Is a VPS cheaper than a commercial email marketing service?

At small scale, a commercial service is often cheaper because it includes deliverability expertise. At scale, self-hosting wins on cost per email, but only if you handle authentication, monitoring, and IP warm-up correctly. The VPS route trades money for your time and technical skill.

How long does it take to warm up a new sending IP?

Four to six weeks is realistic. Start at a few hundred messages per day, double the volume every few days, and keep the bounce rate under 2%. The exact schedule depends on your list size and the receiving providers most of your subscribers use.

Related articles

越南 VPS 提供独立 IPv4,可完全控制邮件信誉。

A Vietnam VPS gives you a dedicated IPv4 and full control over your mail reputation.

越南VPS邮件营销系统搭建要点

在越南VPS上自建邮件营销系统,核心是控制IP信誉。独立IPv4、SPF、DKIM、DMARC和rDNS缺一不可。新IP需要四到六周逐步提升发送量,避免触发垃圾邮件过滤器。使用月付VPS方案可以灵活测试和扩展,无需长期合约。

Note: This guide is for general reference. Every system and infrastructure has its own specifics, so test each step in a safe environment and consult a qualified engineer before applying it in production.