From 55202ba3b0607ef13017253df4e602b4b1263bc7 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 29 Sep 2023 13:20:09 +0200 Subject: [PATCH] delete bounced emails --- app/listmonk/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/listmonk/utils.py b/app/listmonk/utils.py index 3718ee5..1f1e48e 100644 --- a/app/listmonk/utils.py +++ b/app/listmonk/utils.py @@ -77,3 +77,16 @@ def add_email(email): return False return False + +def delete_bounced_emails(): + url = settings.LISTMONK_API + 'bounces' + auth = (settings.LISTMONK_USER, settings.LISTMONK_PASSWORD) + r = requests.get(url + '?per_page=10000', auth=auth) + ids = [sub['subscriber_id'] for sub in r['data']['results']] + url = settings.LISTMONK_API + 'subscribers' + for id in ids: + r = requests.delete(url + '?id=%s' % id, auth=auth).json() + if not r.get("data"): + print(id) + +