decode address if it is bytes

master
vuko 2021-11-13 10:51:16 +01:00
parent 9ad4122061
commit 1e666c572a
1 changed files with 3 additions and 1 deletions

View File

@ -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)