From patchwork Fri Feb 7 13:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Fleischer X-Patchwork-Id: 1494 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 24F8F16E8D499 for ; Fri, 7 Feb 2020 13:09:05 +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=-1.1 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_NONE=-0.0001,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.0] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Fri, 7 Feb 2020 13:09:05 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 0A41418B782C0A; Fri, 7 Feb 2020 13:09:03 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (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 844E318B782C04; Fri, 7 Feb 2020 13:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581080943; bh=MnIJB7tVvPdlIQTvslDtxl/xKLKx34vfmqg4q4GqeB4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=vNP3wZJZ+16DWgcPIorZKSOeH5F0p6uJNboVV15DK9pvsQ+egpLW8FKTKKTrXwf0q K4kppZjdrOYyBzLWW+4Qr4/nW70OyjlCIH+Ulo9/Dq5H49EEsYNwXG8Fda+7kV2rSD VgTv7Cd6Kls4/DfT0NOsOGNm5tuVfPgKTz9SZ45HaL8pFm4MgPu4oMJZ27JjvAUVAM jMyZLuo6qGmf5lTmstrHlgOd7qWudoqc9kuBY7JKsbV3/uYKgAi0IRS3duwCoAl1Cq hRskRpJrNXF5pkyUGz80tWJSjJB0VXGX7RyOmJSj5Nrg5qAvPh3fvMifI8nBPbMULu 6Ks0uRBv5bVlZOSvMc9U6Z4FlRnvre23HgKAwKhQSAQbq7R1UsQ7uZi42KmCuTisAE ggZTDdMG0J+vRZnXt1zz1oQTfB7PqiYkMa7jK4V4KXKHnLILloM4+pQB80hk8rfLLK bKjZpsFyhMBqwhPtyV89ESz5WaJ/IdtPo/bMETshEsVno6DndL22wkAHf2FuyLexoY v2x6GkTPlUfHwOVPRytxTq92NMZHl/+zJ10h2MMJZwb1Eh77WucKATmy9JBtBevwpQ cmdf8yZFep61QTvYxZMn/3eHU2r4Cs/AREvyiA9an7G1Y132dtbotoqOy7PrWqCZkR Tzm4sIp7P+J1zC2gjfIS2Geg= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 6D7B62BFE6; Fri, 7 Feb 2020 13:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1581080943; bh=MnIJB7tVvPdlIQTvslDtxl/xKLKx34vfmqg4q4GqeB4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=lAbfcgvp75kvTbe79OFpvWd4xOWyVv3GoCfskHbEJ8KLmA8tqyK/Y3sPybUTm9Tj2 voiH9S7Mpc7GVqMRObniuVI4C1BQX3LtjD+uewfzfVG1s7oPJZGnaMZxgdJzbHPtVy HS6ynuy1u6PgEN/iPOpnZPG/RZ7kigF8SIXgWhwYR5je2qnHNgc58VTtdhcloh9Aa7 qDQ5VE9ctlPKciP1jwaGdxKnQBzblUkGff2qalH4liwlwA/ws1j1HF2KYGFiMwk6We jXl9UuBMgEMKElBQoYzTkq4uzRdL+bd6F2P2oW9T/DeHWwtk+WLm93T7oj7Y/3TLPV wX4KY+NdTu8di6eOoajvhopVuvZUXsNv5tI7pQwGAUxPCHsyUgJVW/eiQQxsKlWfDK y5yhAcLyFuFMe1bJE3f1RtvfnMJmtSaBkwqlrNOf/LgzrWIx8OoitJw5qwRJQ9XtYG dAp2hX/7EuxZzZePczY9ZncJgWEvslmQ6RR6IgbMc8k1VpX4om+FOfXcPq1vKdvm1c NgqeSf+YcA6W+BQJDuWqGd2f9l5cz3oeJ604MUgE6DusSFuJfKfwGdfnfyBGO3TypO UZP63a7KXIMjaW099SXrb+GY+4z6w3EPcblPphkx/1HS+xrW/zvlZBHCNerbnBe9eg fQFpLbYbiSzQnOU5o7EalVWY= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 8B72A2BFE5 for ; Fri, 7 Feb 2020 13:09:00 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 7 Feb 2020 13:09:00 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 7283F18B782BFE for ; Fri, 7 Feb 2020 13:08:59 +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 3D9CF18B782BFD for ; Fri, 7 Feb 2020 13:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581080939; bh=MnIJB7tVvPdlIQTvslDtxl/xKLKx34vfmqg4q4GqeB4=; h=From:To:Subject:Date:In-Reply-To:References; b=fqc/Iz+pJubEESFlnY8LV5YQz3zjk5gjVw4huHAAstnLWh4NrqhamCimUaBQerGri 5PCN5unQIfz2V49jmGPSsXOriGhv0mURXiDmTB3c+wdiWZzvUaFdZNuqIh2PS0dNgO hqGoOwSNqLMCwcaqy7+eZihIzeop14ek1Z//a/makUnWpBcAheW6R3dwfisnGkhF6r lE9vk6igcfw6Tgaeom15o+DqosMY8EECNoVgy8xgh5ZWMFzzt+Up84X1SPjygR+5uU O6rS1qC2pBfvetj5BoNg+yOmjRU2x/eUiGqFapfqpUIGAdI8L3nWzWyJvYTHetsoHp SPv+2h3gMYJMpyoexOGs84HoNgAqaMp172lGG/csGiCwmTrx3dRjzDxDIroRuVyanX FK5Qe7V20QnqbReut2OjAf0XrYqYP+mbtL76mz8UHF7xfovaDUWaSfWd4YUeK6Jsjx tF5bhmaQUaa0yzRtknnMpHVECKDUOhOJOlaV5pSfkEQtdUw+SUdOHuq2V8P08O84kF IW6NwHZfCvYAgPfrz3rNtl6eeKu1WJL6QAcleJZc7Lxx2og7Qd9wesC9ENLtkf7+M3 H18CGC27oqKrCDvOIJKxMFB3cRSa9eTNcg9fRLOx0gKDaFMDa9UHY2NZbxqly/XE3s 5TWV9LGf6Ya6wJ5m0PbMdCK4= From: Lukas Fleischer To: aur-dev@archlinux.org Subject: [PATCH v2 2/2] Make SMTP port and authentication configurable Date: Fri, 7 Feb 2020 14:09:14 +0100 Message-Id: <20200207130914.86034-2-lfleischer@archlinux.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200207130914.86034-1-lfleischer@archlinux.org> References: <20200207130914.86034-1-lfleischer@archlinux.org> 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 --- Change the default configuration to use localhost. 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 e77ccf4..40cad04 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 = localhost +smtp-port = 25 +smtp-use-ssl = 0 +smtp-use-starttls = 0 +smtp-user = +smtp-password = sender = notify@aur.archlinux.org reply-to = noreply@aur.archlinux.org