From 6a2afb3280c1ea9051ed75adfc1f88203565e323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sun, 23 Jul 2023 13:23:28 +0200 Subject: [PATCH] Various smtpdummy fixes --- config/scripts/smtpdummy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/scripts/smtpdummy b/config/scripts/smtpdummy index 1de7751..8116e7a 100755 --- a/config/scripts/smtpdummy +++ b/config/scripts/smtpdummy @@ -9,7 +9,6 @@ import io import pprint import subprocess import sys -import uuid if __name__ == "__main__": @@ -34,6 +33,7 @@ if __name__ == "__main__": ) parser.add_argument("-l", "--helo", env_var="HELO") + parser.add_argument("-L", "--helo-verb", env_var="HELO_VERB", default="EHLO") parser.add_argument( "-s", "--sender", env_var="SENDER", default="geoffrey@frogeye.fr" ) @@ -79,11 +79,11 @@ if __name__ == "__main__": if args.to is None: args.to = args.receiver[0] if args.reply_to is None: - args.reply_to = args.to + args.reply_to = getattr(args, 'from') if args.password: password = args.password args.password = "********" - mid = f"{uuid.uuid1()}@{args.helo}" + mid = email.utils.make_msgid(domain=args.helo) # Transmission content @@ -190,7 +190,7 @@ Input arguments: if args.security != "starttls": recv() - send(f"EHLO {args.helo}") + send(f"{args.helo_verb} {args.helo}") if args.user: encoded = base64.b64encode( args.user.encode() @@ -200,9 +200,9 @@ Input arguments: + password.encode() ).decode() send(f"AUTH PLAIN {encoded}") - send(f"MAIL FROM: <{args.sender}>" + (" SMTPUTF8" if args.smtputf8 else "")) + send(f"MAIL FROM:<{args.sender}>" + (" SMTPUTF8" if args.smtputf8 else "")) for receiver in args.receiver: - send(f"RCPT TO: <{receiver}>") + send(f"RCPT TO:<{receiver}>") if not args.callout: send("DATA") send(text)