Systems Library / Marketing Automation / How to Build an Email Deliverability Monitoring System
Marketing Automation email marketing

How to Build an Email Deliverability Monitoring System

Track deliverability metrics and get alerts before emails hit spam.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

I set up this email deliverability monitoring system after a client's emails silently hit spam for two weeks. Automated monitoring catches problems before they cost you entire campaigns.

Nobody checks spam folders manually. This system does it and alerts you within hours.

What You Need Before Starting

Step 1: Set Up Seed Accounts

SEEDS = [
    {"provider": "gmail", "email": "[email protected]", "imap": "imap.gmail.com"},
    {"provider": "outlook", "email": "[email protected]", "imap": "imap-mail.outlook.com"},
    {"provider": "yahoo", "email": "[email protected]", "imap": "imap.mail.yahoo.com"},
]

Step 2: Send Test Emails

import smtplib
from email.mime.text import MIMEText
import os

def send_test(to_email, subject, body):
    msg = MIMEText(body)
    msg["Subject"] = subject
    msg["From"] = os.getenv("SMTP_FROM")
    msg["To"] = to_email
    with smtplib.SMTP(os.getenv("SMTP_HOST"), 587) as server:
        server.starttls()
        server.login(os.getenv("SMTP_USER"), os.getenv("SMTP_PASS"))
        server.send_message(msg)

Step 3: Check Inbox Placement

import imaplib
import time

def check_placement(seed, subject, wait=300):
    time.sleep(wait)
    mail = imaplib.IMAP4_SSL(seed["imap"])
    mail.login(seed["email"], seed["password"])
    mail.select("INBOX")
    _, inbox = mail.search(None, f'SUBJECT "{subject}"')
    in_inbox = len(inbox[0].split()) > 0
    spam_folder = "[Gmail]/Spam" if seed["provider"] == "gmail" else "Junk"
    mail.select(spam_folder)
    _, spam = mail.search(None, f'SUBJECT "{subject}"')
    in_spam = len(spam[0].split()) > 0
    mail.logout()
    return {"inbox": in_inbox, "spam": in_spam, "provider": seed["provider"]}

Step 4: Alert on Issues

import requests

def alert_spam(results):
    flagged = [r["provider"] for r in results if r["spam"]]
    if flagged:
        requests.post(os.getenv("SLACK_WEBHOOK"),
            json={"text": f"Deliverability alert: spam on {', '.join(flagged)}"})

Run this before major sends and daily for ongoing monitoring.

What to Build Next

Add SPF, DKIM, and DMARC monitoring. Check DNS records weekly and alert if anything changes.

Related Reading

Want this system built for your business?

Get a free assessment. We will map every system your business needs and show you the ROI.

Get Your Free Assessment

Related Systems