From patchwork Tue Feb 11 11:20:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Fleischer X-Patchwork-Id: 1507 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 EFF1F16FCAFBD for ; Tue, 11 Feb 2020 11:20:39 +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 ; Tue, 11 Feb 2020 11:20:39 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 8FFDC18D703807; Tue, 11 Feb 2020 11:20:31 +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 0F0D918D7037FC; Tue, 11 Feb 2020 11:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581420027; bh=RlGhgetQtuUxnVmPYs6pITn/TcXy9Wu0UYuWReOOojM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=b2qLt4bjTZNbYKYqBlVRXOchI9lRQ5YzUY5dTwNuBscp7zDoTYim0E1LP1kq15z2R EamgsPArGTQE/h3Z4jFOVQmOudZip0pc517+G+UJ249+DgwTHJhiDQDaFCmDfHT2bN GfsMgYr+TuZoFzj5y/OHjosOKlEz3/X/1D4jCU7ISC6XsDjuCU3rA39Lwjzd48pOZR jJ4JssJwde1mq8ZDAMpkAWrhF7ZwYEOsrlfGsbSUrIq8bWjeiMWC3F8U75RZtoFAM3 RqqQF6uowfMNedq+wVlpKu25HrKQaBA99xwsm2hP5mF/+k34Ly3XMLw4eMD/bGnf0v tnJ1aXRca2E8o1heOROWTPPINCG3VC46a/t/hdTs0le1LAoscSf4cS1EpdoyEfeNex ajZmO/DSbyKcXCRDwugUa49j0ggli7wgAkNGjECEfVtZgRy1H4DdoXhmjTnC20MW7W YjgnQS5G/7DwB1iXk+m84j2z+Adof7m2U01P3hwg2mgO6o2Rom+Ni9CjVzA9ofqp5q vdb4QMdhml63F5o/a3muQoSKwvWYXcs024Pee8g/VG6RxeC7S9dVFwJHwu/RmhaPkA HkrEl9aY1OPmhNrfThM4I0KFDdnBPf5HE+xZhtlK/TQXwnlp6eYfnq2uvmQmXMzqab 2CE3WDAk22XMtmm2pXVAO7fA= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id A71F329CE9; Tue, 11 Feb 2020 11:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1581420026; bh=RlGhgetQtuUxnVmPYs6pITn/TcXy9Wu0UYuWReOOojM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=dWcPt7j2/jkJ8ERFtYcDPTlWGwt+2lVM+Wp+EFXdOKiMZvKjuv0YX+c0+ilreu8ab Kq1id1TonvQ2YBBmMO292FkNb0IAFs6G5/JSG0+4c/xZoVe5kmfpwVsDDtYdlC7rH5 Oie8H/gSmOGaKwbhcXNOhX2ZPnJItEUt5ZG2eTgxDj/Ix7RIv8lvwTnXEkIrpu0dfG 37RcVclb+0bM44BEHelvBK4SRWX06NCTQ2AFc7Rdod9zGuDPNQrfKCUsmUZmtxbVxD ealw7tq15Npb2IqqrtMFchep03qdPQ/vPGq+z+ZqL3LsvqB4dlYFF/P9XWsWOkhDir o9oTJomeiEYlsl4wg5BQbIFpNIHXHc+5otkRfItWvsTMCdIarudsW/OvQqEGvz/rNa My1Vs0zFrbDO/enS5ghOXagSW1h/bucFQsCARKZnPK5jIrcYNzSyeF86jyVp6+rq07 vxkQt8qjG2kkRyFzMM/zFfpOGicbyO165mU5rGlV2cQCOWHocoAbtWCjC16ATXTHoG ORYJfec0et7hJiygXaLFWnKOBYgaIziJJWjJAQZWHmuI8XCKqy71LpLDwnxsGqC8Nk 2U4dM9T8ks9J2a4qSYf8XFwS1+a818cYeXB1Apr5IBIHYxzwDocnMnsS4FzwJL/j9P BsG6Ky3K3Y1UQEeGYWzFo2lI= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id D980629CE8 for ; Tue, 11 Feb 2020 11:20:23 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Tue, 11 Feb 2020 11:20:23 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id C677E18D7037D9 for ; Tue, 11 Feb 2020 11:20:22 +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 9A52818D7037D8 for ; Tue, 11 Feb 2020 11:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1581420022; bh=RlGhgetQtuUxnVmPYs6pITn/TcXy9Wu0UYuWReOOojM=; h=From:To:Subject:Date:In-Reply-To:References; b=rHORVuZVn9cAJ2oZTVhSYDn2q5AC1D1P0ukewU9OCE0rahwpE6eRmYfBKbmqYyKU2 wUpSYgNibN+2MeEJY505Ogvg1NGBgt3Z0MKp+wEGWFmsu81V7DgAfLFpAsdN8svVe8 7u6TuOaZ6jTTbgbIqScT2/xtOFYJCppv/Vgmp6JXzmvU9ivLYPj0SF7ggLZFGLfq0L OtrGLjL1k5jzrmc7bD9YqP0YkCIgzV/MvaSZ9tafPBPcjcZLDIfr8e1jXLe87uhcwi V8I44oKKyVUvaqUqIfV11qELw1VQc+GJAjEMJ92cmVQGWwyyRFEZFJt0NcQSltqF7S 8Ac36ZgnbLreqpUWuMnYQ9OE+sDOnIzqrjWN7GjDLwbmPhk2yNdAn/nfcIDvYJ03M6 v8SBARgLWYOR07dgJB0PWIfgWP7fra4m3e1vSE/kTwDxijMOVJYlbsrVtqpqlnkx3B sfrSoDoI5pOCxlIAO49iAtGoGjJvGakFXdMXNU//kSzxDzuK6YSAQz2IyCoW2JKI8m bkkgMAA6lHip8vCG0CmAAyDNF//EKxKKTQtHVWFeukLUPX13qxrUqtdxswIL7dxa7t pFs1lBm9+PhgBwlCel5u+U4AxHnQ8iPAmxLFsyHdn1UU/XiiuQcoAAFUPpRoTzUJ84 vLG6WjZJzWtqJhnqi1x7YkgQ= From: Lukas Fleischer To: aur-dev@archlinux.org Subject: [PATCH v5 2/2] Make SMTP port and authentication configurable Date: Tue, 11 Feb 2020 12:20:38 +0100 Message-Id: <20200211112038.238395-2-lfleischer@archlinux.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200211112038.238395-1-lfleischer@archlinux.org> References: <20200211112038.238395-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 --- 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 6c5c709..5b18a47 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(0) 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