Files
Plushealthtech/tmp-mailtest/smtp_sink.py
T
Clive e5d1446791
Gitea CI/CD / build (push) Successful in 1m40s
Site pages and AI tasks.
2026-08-20 14:58:52 +10:00

28 lines
690 B
Python

import socket, sys, threading
def handle(conn):
conn.sendall(b"220 sink ready\r\n")
buf = b""
while True:
data = conn.recv(65536)
if not data:
break
buf += data
if b"QUIT" in data:
break
open(r"C:\Code\Plushealthtech\tmp-mailtest\raw_capture.bin", "wb").write(buf)
try:
conn.sendall(b"221 bye\r\n")
except Exception:
pass
conn.close()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("127.0.0.1", 2525))
s.listen(1)
print("listening on 127.0.0.1:2525", flush=True)
c, _ = s.accept()
handle(c)
print("done", flush=True)