smtpdummy: Multiple receivers

This commit is contained in:
Geoffrey Frogeye 2021-12-27 16:45:49 +01:00
parent a801c86563
commit b1abd45053
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8

View file

@ -38,7 +38,11 @@ if __name__ == "__main__":
"-s", "--sender", env_var="SENDER", default="geoffrey@frogeye.fr"
)
parser.add_argument(
"-r", "--receiver", env_var="RECEIVER", default="geoffrey@frogeye.fr"
"-r",
"--receiver",
env_var="RECEIVER",
default=[],
action="append",
)
# parser.add_argument("-a", "--auth", env_var="AUTH", default="PLAIN")
parser.add_argument("-u", "--user", env_var="MUSER")
@ -64,12 +68,14 @@ if __name__ == "__main__":
args = parser.parse_args()
# Default values
if not args.receiver:
args.receiver = ["geoffrey@frogeye.fr"]
if args.helo is None:
args.helo = args.origin
if getattr(args, "from") is None:
setattr(args, "from", args.sender)
if args.to is None:
args.to = args.receiver
args.to = args.receiver[0]
if args.password:
password = args.password
args.password = "********"
@ -186,7 +192,8 @@ Input arguments:
).decode()
send(f"AUTH PLAIN {encoded}")
send(f"MAIL FROM: <{args.sender}>")
send(f"RCPT TO: <{args.receiver}>")
for receiver in args.receiver:
send(f"RCPT TO: <{receiver}>")
if not args.callout:
send("DATA")
send(text)