From eeb9566eea4cf187b9272bc5f3bad2ec832333bb Mon Sep 17 00:00:00 2001 From: Eesaan Atluri <atlurie@uab.edu> Date: Mon, 27 Apr 2020 19:00:41 +0000 Subject: [PATCH] send listserv cmds in one email rather than separate emails --- subscribe_mail_lists.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/subscribe_mail_lists.py b/subscribe_mail_lists.py index 8304305..bf0afc9 100644 --- a/subscribe_mail_lists.py +++ b/subscribe_mail_lists.py @@ -31,9 +31,8 @@ def mail_list_subscription(ch, method, properties, body): mail_list_admin = 'root@localhost' #change this during deploy mail_list = 'LISTSERV@LISTSERV.UAB.EDU' - listserv_cmd = {} - listserv_cmd['hpc_announce'] = f'QUIET ADD hpc-announce {email} {fullname}' - listserv_cmd['hpc_users'] = f'QUIET ADD hpc-users {email} {fullname}' + listserv_cmd = f'QUIET ADD hpc-announce {email} {fullname} \ + \nQUIET ADD hpc-users {email} {fullname}' logger.info("Adding user{} to mail list".format(username)) success = False @@ -48,11 +47,10 @@ def mail_list_subscription(ch, method, properties, body): # Create an smtp object and send email s = smtplib.SMTP('localhost') - for key,value in listserv_cmd.items(): - email_msg.set_content(value) - if not args.dry_run: - s.send_message(email_msg) - logging.info(f'This email will add user {username} to {key}\n{email_msg}') + email_msg.set_content(listserv_cmd) + if not args.dry_run: + s.send_message(email_msg) + logging.info(f'This email will add user {username} to {key}\n{email_msg}') s.quit() msg['task'] = task -- GitLab