From f3bfa0f7f9e8cd5f353132f85440b304952957eb Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 15 Oct 2026 23:33:50 +0300 Subject: [PATCH] full auto: freereg voucher claim, domain list, aqbh slider unlock, self-hosted mail_catcher MX (eu.cc denylisted on ForwardEmail), dns_clean jx_del, dns mode prio 5 --- gname_core.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gname_core.py b/gname_core.py index e5b6381..24d1174 100644 --- a/gname_core.py +++ b/gname_core.py @@ -349,6 +349,13 @@ def imap_code(wait=240, min_ts=0): for p in msg.walk(): if p.get_content_type() == "text/html": body_html = p.get_payload(decode=True).decode("utf-8", "ignore") + if not body_html: + # single-part mail: gname sends code mails as ONE text/html part + # (is_multipart()==False) — then `body` holds raw HTML and the + # tag-stripped search below would run on nothing. + if msg.get_content_type() == "text/html" or body.lstrip()[:1] == "<": + body_html = body + body = "" stripped = re.sub(r"\s+", " ", re.sub(r"<[^>]+>", " ", body_html)) subj_raw = msg.get("Subject", "") or "" if ("Reason for failure" in body or "incorrect or has expired" in body @@ -365,10 +372,13 @@ def imap_code(wait=240, min_ts=0): cand = re.sub(r"Dear user\s*\d+", "Dear user", stripped) cand = re.sub(r"Account ID\s*\d+", "Account ID", cand) mm = re.search(r"\b(\d{6})\b", cand) - m.logout() if mm: - return mm.group(1) - m.logout() + code = mm.group(1) + try: m.logout() + except Exception: pass + return code + try: m.logout() + except Exception: pass except Exception as e: log("imap err:", e) time.sleep(6)