From db81193e1789027304d27ff0da6442d3e72e7e1e Mon Sep 17 00:00:00 2001 From: Mark Oudsen Date: Mon, 1 Mar 2021 18:36:28 +0100 Subject: [PATCH] Added transport none,ssl,tls to config.json as smtp_transport (v1.13) --- config/config.json.template | 3 ++- mailGraph.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config/config.json.template b/config/config.json.template index 626c395..5dfd0a9 100644 --- a/config/config.json.template +++ b/config/config.json.template @@ -14,5 +14,6 @@ "zabbix_api_pwd": "astrongpassword", "mail_from": "sender@domain.com", "smtp_server": "localhost", - "smtp_port": 25 + "smtp_port": 25, + "smtp_transport": "none" } \ No newline at end of file diff --git a/mailGraph.php b/mailGraph.php index 5e10499..5f986d7 100644 --- a/mailGraph.php +++ b/mailGraph.php @@ -13,6 +13,7 @@ // 1.10 2021/02/27 - Mark Oudsen - Moved all configuration outside code // 1.11 2021/02/28 - Mark Oudsen - Bugfixes // 1.12 2021/03/01 - Mark Oudsen - Bugfixes - Adding mail server configuration via config.json + // 1.13 2021/03/01 - Mark Oudsen - Added smtp options to encrypt none,ssl,tls // ------------------------------------------------------------------------------------------------------ // // (C) M.J.Oudsen, mark.oudsen@puzzl.nl @@ -369,6 +370,10 @@ $p_smtp_port = 25; if (isset($config['smtp_port'])) { $p_smtp_port = $config['smtp_port']; } + $p_smtp_transport = 'none'; + if ((isset($config['smtp_transport'])) && ($config['smtp_transport']=='tls')) { $p_smtp_transport = 'tls'; } + if ((isset($config['smtp_transport'])) && ($config['smtp_transport']=='ssl')) { $p_smtp_transport = 'ssl'; } + // --- CONFIGURATION --- // Script related settings @@ -687,7 +692,15 @@ _log('# Setting up mailer'); - $transport = (new Swift_SmtpTransport($p_smtp_server, $p_smtp_port)); + if (($p_smtp_transport=='tls') || ($p_smtp_transport=='ssl')) + { + $transport = (new Swift_SmtpTransport($p_smtp_server, $p_smtp_port, $p_smtp_transport)); + } + else + { + $transport = (new Swift_SmtpTransport($p_smtp_server, $p_smtp_port)); + } + $mailer = new Swift_Mailer($transport); $message = (new Swift_Message());