[exim] Warm IP by limiting outgoing SMTP by destination

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Rory Campbell-Lange
Date:  
À: exim-users
Sujet: [exim] Warm IP by limiting outgoing SMTP by destination
I need to warm an IP address that we have been moved to in order to make
it a legitimate SMTP sender for our users who depend on us for alert
messages.

Using the sendgrid suggestions I'm thinking of an arrangement where
certain domains only receive something like 40 emails on the first day,
then double for each subsequent day the IP has gone live.

The maths is something like 40 * (2 ** days-1))

I'm considering a router something like:

    dns_warmup:
        debug_print = "R: dns_warmup for $local_part@$domain"
        driver = dnslookup
        domains = aol.com : yahoo.com
        transport = remote_smtp
        same_domain_copy_routing = no
        condition = ${run{counter.py "$domain"}{yes}{no}
        no_more


with a counter.py file along the lines of the script below.

If it works I can extend it to add some date maths to work out how many
days since the start date and adjust the limit accordingly.

Thoughts gratefully received.

Rory


#!/usr/bin/python

import sqlite3
import sys
from datetime import datetime

# database name
dbname = 'domain_count.db'

def dbinit():
    """database table init"""
    conn = sqlite3.connect(dbname, timeout=3)
    conn.execute(r'''
        CREATE TABLE IF NOT EXISTS domaincounter (
            dater TEXT, domain TEXT, counter INT
        )
    ''')
    conn.commit()


def domain_check(domain, domainlimit):
    """
    Check if the domain is in the db, against today
    """
    domainlimit = int(domainlimit)
    today = datetime.today().strftime("%Y-%m-%d")
    conn = sqlite3.connect(dbname, timeout=3)


    q = conn.execute(r'''SELECT * FROM domaincounter WHERE dater=? AND domain=?''',
        (today, domain))
    r = q.fetchone()


    if not r:
        conn.execute(r'''INSERT INTO domaincounter VALUES (?, ?, ?)''',
            (today, domain, 1)
        )
        conn.commit()
        return True


    else:
        # if over limit return
        if r[2] >= domainlimit:
            conn.commit()
            return False


        # update record
        conn.execute(r'''UPDATE domaincounter SET dater=?, domain=?, counter=?''',
            (today, domain, r[2] + 1))
        conn.commit()
        return True



if __name__ == '__main__': 
    # read sys.argv1 (domain name and domainlimit from exim)
    try:
        domain = sys.argv[1]
    except:
        sys.exit(1)


    # hardcoded at the moment
    domainlimit = 40


    dbinit()


    dc = domain_check(domain, domainlimit)
    if not dc:
        sys.exit(1)
    else:
        sys.exit(0)