From patchwork Fri Feb 7 12:53:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Fleischer X-Patchwork-Id: 1493 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 977F716E8C761 for ; Fri, 7 Feb 2020 12:53:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1, MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001, T_DMARC_POLICY_NONE=0.01 autolearn=ham autolearn_force=no version=3.4.3 X-Spam-BL-Results: [127.0.0.11] [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Fri, 7 Feb 2020 12:53:21 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 7C55C18B78289C; Fri, 7 Feb 2020 12:53:11 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id 20E5F18B782896; Fri, 7 Feb 2020 12:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581079991; bh=Vv5Quom853ySwEYnoFTjIL9OSGrzU200HAjEhQd4EC8=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=c8VjVGrQ/IJaf9/N7N3MOkr5BesqSZPlyxdV+iEOUZViw7aJqZwlhfhJVZ4/usUex KRo1GYoIxcWKez2jl3Svcff2GSHtCcHvnY56T/nSmNarejMWr9EGm7gCMLE/Ewg4lX TEkK4LQqc19fyJYaTpTsIxJJYxc3tJI6BZ2JueurW//e2rBKT/6CiK1bj+5pp6VIWH LqoaFeN/G6OUQu2d9D+ODsP7ubeMjY9Xk6yn1v9CowvbxTVgQ2yypwJw+fKhGa0sf6 GPeOvzm6pk8asUwn2YxGqbEwtoVDE0Fu2t/uE8StI556eiAdyBx+40fFdh+4KvqjcJ ZKBM3tYO7sqsX4xPvq2vWmlIubYsiM1GxUMVe6uGS0dSiHupQGEVuQy+emkCh1mF7Z tMA+gKda7SO6EWAPVoCLibJqD/gBQnTbFsxgoJiQFlKcoNgqJGl5PVjDkeUGUnAaTH iBiMtWbKxjEIgqMpeviy4zt1o9uDIFba4eDn1CAw59VN8+8gRVJnDe9OSmFgsv8nms NZs3IMF8nmljwOR8Iota5DOe3ddh0Td7RD5Z+90Y3YwQGNWVioSkZ9zONCEklYqkkB OSZzPJsI8B2WhgovSdaJu6XIBOEQkBmNMjiNe53pZfWo6HQcjOuDajPld9dnYqsit6 HNogE0HEWCkApShnJudKX2WI= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 0E2F32BFE7; Fri, 7 Feb 2020 12:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1581079991; bh=Vv5Quom853ySwEYnoFTjIL9OSGrzU200HAjEhQd4EC8=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=EgqrVA/RLItmPuFBBcT5u9pNF59GuPbqyjkRiASKAfc5gxYGhIEIQmjH+frXMdo8o PuTPDT7kLz06y4zzHaJvzeeV+st9BsV3M1YgP1wnCNakde7bKLHRicdvPVoP6adMBW kM4389CkujLY3X4xnjteQOfZ6xYKLWb/afok69Wy1ypVo/dBk56OB5NY0G+zEhADdk bdnA1PHg9XiOVR6E/XE3fMXaPTvmukm3tQ6vc/04KrMZWCdDgibLRAQx4MG85dOj+y tRg9xHZPbsIDERM5XR0KUCgf6S8+QE3nju9XZgqHH/ub3kAdZ2LcJu/UGAsMenUy7s fpxtwt92q0QNt6j9QmK+RGBD+F+lwB7n8j+SRos2sGKnl2IBDMabZT6mvy6ghcDZbQ SfjqbC5J3GKiOyBS6j642/zz4Ao5s7QEaNkw2OntvccsoBzsja9E3ltaPXdpYdQQg8 nUAkj5bewXlKauESPfsf8ZiJJzRW7BE4Xj+MciwyJuQnSYgwE7E1s3cJN2TZqzHKZq qQwhHFO2aor0Yej0JmgjD35/sI0fOWe6YPfpKxnofJtod+dRVHiaoBgDC6fBijzpf5 oqNojW6JMweuMmnbFwdg75r6QJsMBv0IH6yvv4GYkdZorErJJxrbfpXEoZjms0+d5D ROf0kN6R4BjvIU5kERUezGLI= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id D43372BFE6 for ; Fri, 7 Feb 2020 12:53:06 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 7 Feb 2020 12:53:06 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 7F70918B782892 for ; Fri, 7 Feb 2020 12:53:05 +0000 (UTC) Received: from localhost (HSI-KBW-091-089-090-042.hsi2.kabelbw.de [91.89.90.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: lfleischer) by orion.archlinux.org (Postfix) with ESMTPSA id 4793A18B782891 for ; Fri, 7 Feb 2020 12:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581079985; bh=Vv5Quom853ySwEYnoFTjIL9OSGrzU200HAjEhQd4EC8=; h=From:To:Subject:Date; b=wiw2BjsyyecvSDgUah1lnIsmRemo6/ME4N/tQB94k00/00CyroUH1Yb4Ur3m2bSsD llcSJLFTe9p1o9Mi4lpWiWoe/k6J9hpLWyld++1X8M1YTttnbPPPob84bAIg2wREwk gLdm7Mzmx8oV3p4qjBRbC8mma1KPLURrPNoUqHVT+YeQdOXHHeWl7oj3WrpZ//RYD1 6vFanDFJLRmbkzy00E7h3lD6YekoFjRs+EV+NwkhIHmMNA1Ve6NgV+PxPTyBEmcv6Y jg6pm0vNDaA/xkh4a9jX76s3aDmsYYbsskCd/q3Y7IuwI9KSaJ0IZuNt6VWv9q+YcO XMa651g+F8OsQyd3eeEvwFipYX4XzV7j4SlScB7yyL6nuXtmpeIUnwGANg4jSn4f0P pl39Axb5OUGQmus+vwByazvI9JZ56O1b0v6zvfepBr3hUhdpQfQPVq5m86CFNC+eDL VrB1V0tJD79XeFIbkjmUDWpiDxZ3Dhj/Oq8vP+sLq4/qYcZrjVHWPUT/YQRdyrX90O w7hNOWv9WDuKSlZ0quVEJ8bOuP0tUwNgpQejPtCyRxorCE9r9PKUiTKNFRHz+WvxoS GW/g1pMzXJsOWjvbIuy/M6Vat4qE11KHJT2nY9i1xPylEntGts+49BPBkdS6wlrafj DJ7P41BtajXK1WQ2v7HYxHjA= From: Lukas Fleischer To: aur-dev@archlinux.org Subject: [PATCH] Make SMTP port and authentication configurable Date: Fri, 7 Feb 2020 13:53:20 +0100 Message-Id: <20200207125320.84490-1-lfleischer@archlinux.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-BeenThere: aur-dev@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Arch User Repository \(AUR\) Development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: aur-dev-bounces@archlinux.org Sender: "aur-dev" Signed-off-by: Lukas Fleischer --- aurweb/scripts/notify.py | 19 ++++++++++++++++++- conf/config.defaults | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/aurweb/scripts/notify.py b/aurweb/scripts/notify.py index 35d2701..ddf4736 100755 --- a/aurweb/scripts/notify.py +++ b/aurweb/scripts/notify.py @@ -65,6 +65,11 @@ class Notification: def send(self): server_addr = aurweb.config.get('notifications', 'smtp-server') + server_port = aurweb.config.getint('notifications', 'smtp-port') + use_ssl = aurweb.config.getboolean('notifications', 'smtp-use-ssl') + use_starttls = aurweb.config.getboolean('notifications', 'smtp-use-starttls') + smtp_user = aurweb.config.get('notifications', 'smtp-user') + smtp_passwd = aurweb.config.get('notifications', 'smtp-password') sender = aurweb.config.get('notifications', 'sender') reply_to = aurweb.config.get('notifications', 'reply-to') reason = self.__class__.__name__ @@ -85,7 +90,19 @@ class Notification: for key, value in self.get_headers().items(): msg[key] = value - server = smtplib.SMTP(server_addr) + if use_ssl: + server = smtplib.SMTP_SSL(server_addr, server_port) + else: + server = smtplib.SMTP(server_addr, server_port) + + if use_starttls: + server.ehlo() + server.starttls() + server.ehlo() + + if user and password: + server.login(user, passwd) + server.set_debuglevel(1) server.sendmail(sender, recipient, msg.as_bytes()) server.quit() diff --git a/conf/config.defaults b/conf/config.defaults index af85ce8..83820c0 100644 --- a/conf/config.defaults +++ b/conf/config.defaults @@ -48,6 +48,11 @@ window_length = 86400 [notifications] notify-cmd = /usr/local/bin/aurweb-notify smtp-server = orion.archlinux.org +smtp-port = 587 +smtp-use-ssl = 0 +smtp-use-starttls = 1 +smtp-user = aur +smtp-password = aur sender = notify@aur.archlinux.org reply-to = noreply@aur.archlinux.org