From 1e666c572a18687799479905b1c5040440297154 Mon Sep 17 00:00:00 2001 From: vuko Date: Sat, 13 Nov 2021 10:51:16 +0100 Subject: [PATCH] decode address if it is bytes --- hsadmin/cmd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hsadmin/cmd.py b/hsadmin/cmd.py index 8800a3d..c01b0b7 100644 --- a/hsadmin/cmd.py +++ b/hsadmin/cmd.py @@ -79,6 +79,7 @@ def main(): user = input("User: ") p = k.get_principal(user) + password = generage_password() if args.email_address is not FROM_LDAP: address = args.email_address @@ -143,7 +144,8 @@ def send_mail(admin, admin_password, password, user, address): msg.set_content(mail_template.render(config)) msg["Subject"] = f"Password reset for {user}@hackerspace.pl" msg["From"] = f"{admin}@hackerspace.pl" - msg["To"] = address + msg["To"] = address.decode() if isinstance(address, bytes) else address + with smtplib.SMTP_SSL("mail.hackerspace.pl") as s: s.login(admin, admin_password)