From patchwork Mon Feb 10 19:53:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Fleischer X-Patchwork-Id: 1503 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 DC60416F97E13 for ; Mon, 10 Feb 2020 19:53:01 +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.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 10 Feb 2020 19:53:01 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 8334D18CF1CAAF; Mon, 10 Feb 2020 19:52:57 +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) server-digest SHA256) (No client certificate requested) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id 33E7B18CF1CAA8; Mon, 10 Feb 2020 19:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581364377; bh=wCAdf2z6m9vzLP5oilqwtVtsFdNA9ezZW/quNMIR1/c=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=aANDiZp1TNyHfVTRokLc8ODnDs5c7VEt4OYkpiwTCKQTrIdqOkGcJs2Z+A4QrIuL+ 33SsV/fiFoTf4eZ28KsJIevSOTtO26tDUHEmKMjuyoT1NzCBY1ulh+Nqmb2Ym+Dqrd zi1fMBr2elLoMO81sMjcvOb/A0c/JQRopUjpmrqyQuNSdKHSkUNVz6Q2BXGZ3+6SYP BRoi7V6fmHcq1W+9JeIncY/dPQZ63chuO6iVPfpibOAbhBP0wBQ8oP809gpJskjVlT OgU8lvb/GsjkEGNT7A5xC8aiaWwoojGJbMrVeRNhrTONTuICTCh0EMa1jjs7uQY5Pt Le/AtTnTOKgbsQB395TikdlOApkuKM2Ih8brfcREakUi8vVvaPN1IazQFGIo4lw3sr itlJz4zPDC1JfbXY5pSW8W4N3pPT+jzHqE8cQQKlOI0SVlLdABn0vjFdYSRCsflTM7 vMpTNoimtzs9T+sKEyeUmK9EpFkxsguivClLA9o1Dwr/8J7w7DHgj7PiXKbQDaM+ou gronB0YIOcbg5PRc93F1nO3qOCfBao1LUj5+woEP6eNSpSnwpz9mWNU2OXcWKA4kIz IANta4L3aK7qQPv82U7A0FE10s9rEW2hrZ5icWfp4k9A3LvfEIhjYizdLY/psqwbmM 1fVGw9uraP6SuZ8jljioB2aI= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id CE8522BFE3; Mon, 10 Feb 2020 19:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1581364376; bh=wCAdf2z6m9vzLP5oilqwtVtsFdNA9ezZW/quNMIR1/c=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=C3iMSzRw4WwgDLS6+tn1Askt2+1i7khauEyzdxx8SP48stlTW/xoce2FIyvAnzZ6Y 1Bk0teQmbwq3z1baSSvrfkT8B0bfTYZhvr436oGx389ZBL8taR463zHVQcMyCpD9zk +HBSe4IhrG8TsFJeUJp75EU9snkuOy82IOMvZ4iLDndF/yHVg/ZIz2Zrx7hdalNwqp DaLteE/p/g9l9rUPk6cZ3Gn8vdAk0gpe8+WD1zJ9MPlU1BT7mYhu/+QqyK0azCwkeS MvjAm50yZXqRBI2RwajSOk7dAPtnsBDTMzlF4yDTTksQqD+mjepZw+SnfRAg5oNmi8 P17Giwpjf2lJpI4vRjTZyzTrvf9DlkwFvfKP62hXC1iu613KSAV61Moxsf0ZbycqM5 IdBNSSODe6U9pJMfM2Ukjz7UWjvxWXZcld2orgfIjeZXWg2/a5FwsR/9fo7bRFN6sR trOXoNz3dfOWhjL47eYml8/+NccpQQGe1FWhYLA/cHHXUxh0DmarAE8YB8RANCwANB cRi1W/ao9EsqkHzuILQQd4dm5X2qp89oUG38QBOMkVZx6f5bEp4GyUTtEneFBKFOJ0 64QHF3CIrDJOhjX0VDc0JNeM0Q2FbH2rpGzDG+ztYs2Ee8t1JtFCtp9N0Hwp2H1ngf /A4YCRxOkbMTpuyiLLtMpptI= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id A840C2BFE2 for ; Mon, 10 Feb 2020 19:52:53 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 10 Feb 2020 19:52:53 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 82E3018CF1CAA0 for ; Mon, 10 Feb 2020 19:52:52 +0000 (UTC) Received: from localhost (unknown [IPv6:2a02:8070:24e4:b800:b66b:fcff:fe3e:6273]) (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 51D1318CF1CA9F for ; Mon, 10 Feb 2020 19:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581364372; bh=wCAdf2z6m9vzLP5oilqwtVtsFdNA9ezZW/quNMIR1/c=; h=From:To:Subject:Date:In-Reply-To:References; b=Ngi9vEaKlgME4QlzWwKhsAr/o9TpyQ6JdcBrli50d6ZgGWt/xqOLh7MBf6ZhUtcMj IFS4CdOpDrTcqWf735/t7GUH+iQCe5rlUTg2R7S6B5Xo7gtT1sTAMwpiMrvNsuejWN Onok9gEVQP8oW4tGWQYbqvBEERZl+OspmQoq+z7aqIa5M1YzABMA0rzymJlSqEmrav Hi8NTc9gfx/h+YG/pmxJz2ig09Gz2e0ctBehV5WJhhLvGFiJyCDubdj4Bu+vqKlsl9 HMvPSM+TX1MItxi/XNR0CsII0Uj/Twt+O2TMNOKRytOuc7aukPptWaa878PxE2URxg vqA9vLaXpZ2BfbPeEEZTAD6pHTmXJVYvHWMtizknWKv1UyfSJOHmjiSS3MveVoe1b2 1j2qQomxCai663+9ZiCYPKbWRN0t0wQvi7UsBT1M/Ut/fpKhb9rwJgGCoj+gC1Mzv1 9maS10GelUBK40ft8lRy6K2BA8G7OT6CCKtvdk46P0npv+qgiGH2gK9dYP0bmH7Qy5 lORVYRRmRF9HWPWsfrVrHIgfO2nHDSVRlygzqa3opJJkVTmL601wrZpjJSMT9uF6n8 BSOx0nTp1Rjnlr9UrlOD9tSQlvF7h7o+1k9sRbCUVpb8fzvChAq449swPNjYIz1kdr qY4qoEsfxZYbfd+pX5bDNr94= From: Lukas Fleischer To: aur-dev@archlinux.org Subject: [PATCH v4 2/2] Make SMTP port and authentication configurable Date: Mon, 10 Feb 2020 20:53:10 +0100 Message-Id: <20200210195310.145150-2-lfleischer@archlinux.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210195310.145150-1-lfleischer@archlinux.org> References: <20200210195310.145150-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" Add more options to configure the smtplib implementation for sending notification emails. The port can be changed using the new smtp-port option. Encryption can be configured using smtp-use-ssl and smtp-use-starttls. Keep in mind that you usually also need to change the port when enabling either of these options. Authentication can be configured using smtp-user and smtp-password. Authentication is disabled if either of these values is empty. Signed-off-by: Lukas Fleischer --- Fix variable naming inconsistency with the user and passwd variables. aurweb/scripts/notify.py | 20 +++++++++++++++++++- conf/config.defaults | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/aurweb/scripts/notify.py b/aurweb/scripts/notify.py index 941187e..31b78e9 100755 --- a/aurweb/scripts/notify.py +++ b/aurweb/scripts/notify.py @@ -65,6 +65,7 @@ class Notification: return body.rstrip() def send(self): + sendmail = aurweb.config.get('notifications', 'sendmail') sender = aurweb.config.get('notifications', 'sender') reply_to = aurweb.config.get('notifications', 'reply-to') reason = self.__class__.__name__ @@ -95,8 +96,25 @@ class Notification: else: # send email using smtplib; no local MTA required 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') + user = aurweb.config.get('notifications', 'smtp-user') + passwd = aurweb.config.get('notifications', 'smtp-password') + + 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 passwd: + server.login(user, passwd) - server = smtplib.SMTP(server_addr) server.set_debuglevel(1) server.sendmail(sender, recipient, msg.as_bytes()) server.quit() diff --git a/conf/config.defaults b/conf/config.defaults index 23d46b0..b69d031 100644 --- a/conf/config.defaults +++ b/conf/config.defaults @@ -49,6 +49,11 @@ window_length = 86400 notify-cmd = /usr/local/bin/aurweb-notify sendmail = 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