From 1c2e263bb72a7ff5a295e73607de1a4bc3581f4d Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 9 Jun 2026 20:31:45 -0500 Subject: [PATCH] warmup(ip-rehab): bias recipients to multi-subscriber business domains (cut bounce) Day-0 batch saw ~45% bounce because 'no listmonk bounce record' is a weak liveness signal. Now require the recipient's domain to have >=2 enabled subscribers (a real org, not a one-off typo'd address), which materially lowers the dead-mailbox bounce rate on the recovering IPs. --- scripts/ip_rehab.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/ip_rehab.py b/scripts/ip_rehab.py index 3952cbb..5346849 100644 --- a/scripts/ip_rehab.py +++ b/scripts/ip_rehab.py @@ -79,9 +79,19 @@ def pick_recipients(n: int, exclude: set[str]) -> list[tuple[str, str]]: Queried via `docker exec psql` since the host has no pg driver. """ consumer_list = "(" + ",".join("'%s'" % d for d in CONSUMER) + ")" + # Bias toward higher-deliverability recipients on a recovering IP: + # - real business/ISP domains (never consumer) + # - never recorded a bounce in listmonk + # - domain has >= 2 enabled subscribers (a real org, not a one-off typo'd + # address) -- this materially cuts the dead-mailbox bounce rate. sql = ( + "WITH dom AS (" + " SELECT lower(split_part(email,'@',2)) AS d, count(*) AS c " + " FROM subscribers WHERE status='enabled' GROUP BY 1 HAVING count(*) >= 2" + ") " "SELECT s.email, COALESCE(s.name,'') " "FROM subscribers s " + "JOIN dom ON dom.d = lower(split_part(s.email,'@',2)) " "WHERE s.status='enabled' " f"AND lower(split_part(s.email,'@',2)) NOT IN {consumer_list} " "AND NOT EXISTS (SELECT 1 FROM bounces b WHERE b.subscriber_id=s.id) "