From 1ad35ce521f4d25f399616fc12280ea74507349c Mon Sep 17 00:00:00 2001 From: Atanas Zhelev Date: Feb 12 2020 13:39:00 +0000 Subject: Add smtp authentication support to koji-gc --- diff --git a/util/koji-gc b/util/koji-gc index a8f0bef..2c8efa8 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -76,6 +76,10 @@ def get_options(): help=_("show xmlrpc debug output")) parser.add_option("--smtp-host", metavar="HOST", help=_("specify smtp server for notifications")) + parser.add_option("--smtp-user", dest="smtp_user", metavar="USER", + help=_("specify smtp username for notifications")) + parser.add_option("--smtp-pass", dest="smtp_pass", metavar="PASSWORD", + help=optparse.SUPPRESS_HELP) # do not allow passwords on a command line parser.add_option("--no-mail", action='store_false', default=True, dest="mail", help=_("don't send notifications")) parser.add_option("--send-mail", action='store_true', dest="mail", @@ -138,6 +142,8 @@ def get_options(): ['server', None, 'string'], ['weburl', None, 'string'], ['smtp_host', None, 'string'], + ['smtp_user', None, 'string'], + ['smtp_pass', None, 'string'], ['from_addr', None, 'string'], ['email_template', None, 'string'], ['email_domain', None, 'string'], @@ -416,6 +422,8 @@ Build: %%(name)s-%%(version)s-%%(release)s print("Sending warning notice to %s" % msg['To']) try: s = smtplib.SMTP(options.smtp_host) + if options.smtp_user is not None and options.smtp_pass is not None: + s.login(options.smtp_user, options.smtp_pass) s.sendmail(msg['From'], msg['To'], msg.as_string()) s.quit() except: diff --git a/util/koji-gc.conf b/util/koji-gc.conf index a657c20..eff0704 100644 --- a/util/koji-gc.conf +++ b/util/koji-gc.conf @@ -26,6 +26,10 @@ weburl = https://koji.fedoraproject.org/koji # when creating email notifications #email_domain = fedoraproject.org +# SMTP user and pass (uncomment and fill in if your smtp server requires authentication) +#smtp_user=user@example.com +#smtp_pass=CHANGEME + [prune] policy = #stuff to protect