Emails from your iRedMail server going to Gmail spam folder? Learn how to set up SPF, DKIM, DMARC, PTR records, and warm up your IP address for perfect deliverability.

You’ve set up iRedMail. SSL certificates are working. Authentication is perfect. But there’s one problem: emails from your server go straight to Gmail’s spam folder. Or worse—they never arrive at all.

You’re not alone. This is the single biggest frustration for new email server administrators. Gmail, Outlook, and Yahoo have strict requirements for accepting email from unknown servers. Without proper configuration, your legitimate emails look like spam to their filters.

The good news: deliverability is 100% fixable. Major email providers have published clear requirements. Once you meet them, your emails will land in the inbox every time.

In this guide, I’ll walk you through the 5 essential email authentication standards that determine deliverability: SPF, DKIM, DMARC, PTR, and IP warming.


Why Gmail Blocks Your Emails

Gmail and other providers use automated scoring systems. Each email receives a “spam score” based on multiple factors:

FactorWeightDescription
SPFHighIs the sending IP authorized?
DKIMHighIs the email signature valid?
DMARCHighWhat to do if SPF/DKIM fail?
PTR RecordMediumDoes IP reverse-resolve to hostname?
IP ReputationHighHas this IP sent spam before?
ContentMediumDoes email look like spam?

Missing any of the first three almost guarantees spam folder placement.


Step 1: Set Up SPF (Sender Policy Framework)

SPF tells receiving servers which IP addresses are authorized to send email for your domain.

Generate SPF Record

For a typical iRedMail setup, your SPF record should look like:

v=spf1 mx ip4:YOUR_SERVER_IP ~all

Components:

  • v=spf1 – SPF version
  • mx – Allow your MX servers
  • ip4:YOUR_SERVER_IP – Allow your server’s IP
  • ~all – Soft fail for other IPs (or -all for hard fail)

Add to DNS

  1. Log into your domain’s DNS control panel
  2. Add a TXT record for your domain (not a subdomain)
  3. Name/Host: @ or your domain name
  4. Value: v=spf1 mx ip4:203.0.113.0 ~all (replace with your IP)

Verify SPF

dig TXT yourdomain.com | grep spf
# OR
nslookup -type=TXT yourdomain.com

Expected output:

"v=spf1 mx ip4:103.207.87.115 ~all"

Step 2: Set Up DKIM (DomainKeys Identified Mail)

DKIM adds a digital signature to every outgoing email. iRedMail generates DKIM keys automatically.

Find Your DKIM Key

# For iRedMail with OpenDKIM
sudo amavisd-new showkeys
# OR
sudo cat /var/lib/dkim/yourdomain.com.txt

Expected output format:

mail._domainkey IN TXT "v=DKIM1; h=sha256; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK..."

Add DKIM Record to DNS

  1. Add a TXT record for mail._domainkey.yourdomain.com
  2. Name/Host: mail._domainkey
  3. Value: The entire string from v=DKIM1 to the end

Verify DKIM

dig TXT mail._domainkey.yourdomain.com

Test sending an email:

echo "Test DKIM" | mail -s "DKIM Test" test@yourdomain.com

Check headers for DKIM-Signature and Authentication-Results.


Step 3: Set Up DMARC (Domain-based Message Authentication)

DMARC tells receiving servers what to do when SPF and DKIM fail.

Create DMARC Record

Add this TXT record to your DNS:

_dmarc.yourdomain.com. TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@yourdomain.com; ruf=mailto:dmarc-reports@yourdomain.com; fo=1"

Policy options:

PolicyAction
p=noneMonitor only (no action)
p=quarantineMark as spam
p=rejectReject the email entirely

Start with p=none to monitor, then move to p=quarantine or p=reject.

Add DMARC Record

  1. Add a TXT record for _dmarc.yourdomain.com
  2. Name/Host: _dmarc
  3. Value: v=DMARC1; p=quarantine; rua=mailto:admin@yourdomain.com

Verify DMARC

dig TXT _dmarc.yourdomain.com

Step 4: Set Up PTR Record (Reverse DNS)

PTR records are controlled by your hosting provider, not your DNS.

Check Current PTR

dig -x YOUR_SERVER_IP

Expected output:

;; ANSWER SECTION:
xxx.xxx.xxx.xxx.in-addr.arpa. 86400 IN PTR mail.yourdomain.com.

Request PTR from Hosting Provider

Contact your VPS/cloud provider support and request:

Please set the PTR record for IP YOUR_SERVER_IP to mail.yourdomain.com

Providers and their policies:

ProviderPTR Policy
DigitalOceanCan set via control panel
LinodeCan set via control panel
VultrCan set via control panel
AWSRequires support ticket
HetznerCan set via robot panel
OVHRequires support ticket

Verify PTR

# Get the PTR hostname
dig -x YOUR_SERVER_IP +short

# Then check that hostname resolves back to your IP
dig PTR_HOSTNAME +short

Both commands should return your server’s IP address.


Step 5: Warm Up Your IP Address

New IP addresses have no reputation. You need to gradually increase sending volume.

IP Warming Schedule

WeekDaily VolumeNotes
Week 110-50 emailsPersonal emails only
Week 250-200 emailsAdd a few more senders
Week 3200-1000 emailsRegular business email
Week 41000+ emailsFull sending volume

Monitor Reputation

Use these free tools:

  • Google Postmaster Tools – Google’s official reputation dashboard
  • MXToolbox Blacklist Check – Check if your IP is listed
  • SenderScore.org – Reputation score (0-100)
  • Talos Intelligence – Email reputation lookup

Step 6: Additional Deliverability Factors

Use TLS Encryption

Your server should encrypt email in transit:

sudo postconf -e "smtp_tls_security_level = may"
sudo postconf -e "smtp_tls_mandatory_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1"
sudo postconf -e "smtp_tls_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1"

Avoid Spam Trigger Words

Common spam trigger words to avoid:

  • “Free”, “Winner”, “Guaranteed”
  • “Act now”, “Limited time”
  • ALL CAPS subject lines
  • Multiple exclamation marks!!!
  • “Click here”, “Unsubscribe” (only in footer)

Set Proper Rate Limits

# Limit outgoing emails per second
sudo postconf -e "smtp_destination_rate_delay = 5s"
sudo postconf -e "smtp_destination_concurrency_limit = 2"

Complete Verification Script

Run this on your server to check all deliverability settings:

#!/bin/bash
DOMAIN="yourdomain.com"
IP=$(curl -s ifconfig.me)

echo "=== Email Deliverability Check ==="
echo "Domain: $DOMAIN"
echo "Server IP: $IP"
echo ""

echo "--- SPF Check ---"
dig TXT $DOMAIN +short | grep spf && echo "✅ SPF configured" || echo "❌ SPF missing"

echo ""
echo "--- DKIM Check ---"
dig TXT mail._domainkey.$DOMAIN +short | head -c 100 && echo "... ✅ DKIM configured" || echo "❌ DKIM missing"

echo ""
echo "--- DMARC Check ---"
dig TXT _dmarc.$DOMAIN +short && echo "✅ DMARC configured" || echo "❌ DMARC missing"

echo ""
echo "--- PTR Check ---"
PTR=$(dig -x $IP +short)
echo "PTR record: $PTR"
if [[ "$PTR" == *"$DOMAIN"* ]]; then
    echo "✅ PTR matches domain"
else
    echo "❌ PTR does not match domain"
fi

echo ""
echo "--- Blacklist Check ---"
for BL in "zen.spamhaus.org" "bl.spamcop.net" "b.barracudacentral.org"; do
    if dig +short $REV.$BL | grep -q "127.0.0"; then
        echo "❌ IP listed on $BL"
    else
        echo "✅ Clean on $BL"
    fi
done

Conclusion

Email deliverability is not magic—it’s technical. By implementing these five standards, your emails will land in the inbox:

StandardPurposeUrgency
SPFAuthorize sending IPs✅ Required
DKIMCryptographically sign emails✅ Required
DMARCDefine handling of failures✅ Required
PTRMatch IP to hostname✅ Required
IP WarmingBuild reputation⏳ Recommended

Your iRedMail server is now fully deliverable to Gmail and other major providers.