From 0cd169a9d2c11dfd94df17ab897ce465e88edca2 Mon Sep 17 00:00:00 2001 From: Mark Oudsen Date: Mon, 10 Jul 2023 14:32:47 +0200 Subject: [PATCH] v2.14 - Adding ability to set 'From' and 'Reply-to' address details in configuration --- README.md | 7 ++++++- config/config.json.template | 2 ++ config/config.json.template.multigraph | 2 ++ mailGraph.php | 17 ++++++++++++++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de1e6f8..062fec6 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,12 @@ _This version has been verified with Zabbix 5.4 and 6.0 LTS and is expected to w Release notes - Adding the ability to define FROM details for the emails generated by mailGraph - `smtp_from_address` to set the from mail address (if not set uses mailing system default). Note: obsolete `mail_from` but retained for backwards compatibility. - - `smtp_from_name` to set the name that goes with the mail address (if not set uses "mailGraph") + - `smtp_from_name` to set the name that goes with the mail address (if not set uses "mailGraph"). +- Adding the ability to define REPLY_TO details for the emails generated by mailGraph + - `smtp_reply_address` to set the reply-to mail address (if not set, no reply-to will be added to the message). + - `smtp_reply_name` to set the reply-to name of the mailbox (if not set defaults to "mailGraph feedback"). +- Adding a new URL for use in the template: + - `ACK_URL` points to the function in Zabbix for editing and submitting an Acknowledge statement. ## mailGraph v2.13 release ## _(2023/07/03)_ diff --git a/config/config.json.template b/config/config.json.template index 7943a54..8e42344 100644 --- a/config/config.json.template +++ b/config/config.json.template @@ -19,6 +19,8 @@ "smtp_transport": "none", "smtp_from_address": "mailgraph@mydomain.com", "smtp_from_name": "mailGraph", + "smtp_reply_address": "feedback@mydomain.com", + "smtp_from_name": "mailGraph response mailbox", "smtp_strict": "yes", "graph_match": "any", "period": "20m", diff --git a/config/config.json.template.multigraph b/config/config.json.template.multigraph index f1ab5e3..8eb181d 100644 --- a/config/config.json.template.multigraph +++ b/config/config.json.template.multigraph @@ -20,6 +20,8 @@ "smtp_strict": "yes", "smtp_from_address": "mailgraph@mydomain.com", "smtp_from_name": "mailGraph", + "smtp_reply_address": "feedback@mydomain.com", + "smtp_from_name": "mailGraph response mailbox", "graph_match": "any", "periods": "10m,4h,2d,7d", "periods_headers": "Last 10 minutes,Last 4 hours,Last 2 days,Last 7 days", diff --git a/mailGraph.php b/mailGraph.php index 46a180e..4876b36 100644 --- a/mailGraph.php +++ b/mailGraph.php @@ -53,7 +53,8 @@ // Added ability to locate latest problems for testing purposes // 2.12 2023/07/02 - Mark Oudsen - Replaced SwiftMailer with PHPMailer (based on AutoTLS) // 2.13 2023/07/03 - Mark Oudsen - Bugfixes speciifally on links into Zabbix (missing context or info) - // 2.14 2023/07/10 - Mark Oudsen - Adding ability to set 'From' address in configuration + // 2.14 2023/07/10 - Mark Oudsen - Adding ability to set 'From' and 'ReplyTo' addresses in configuration + // Adding ACK_URL for utilization in the template to point to Ack page // ------------------------------------------------------------------------------------------------------ // // (C) M.J.Oudsen, mark.oudsen@puzzl.nl @@ -599,6 +600,12 @@ $p_smtp_from_name = 'mailGraph'; if (isset($config['smtp_from_name'])) { $p_smtp_from_name = $config['smtp_from_name']; } + $p_smtp_reply_address = ''; + if (isset($config['smtp_reply_address'])) { $p_smtp_reply_address = $config['smtp_reply_address']; } + + $p_smtp_reply_name = 'mailGraph feedback'; + if (isset($config['smtp_reply_name'])) { $p_smtp_reply_name = $config['smtp_reply_name']; } + // >>> Backwards compatibility but smtp_from_address is leading (Sender = $p_smtp_from_address; $mail->SetFrom($p_smtp_from_address, $p_smtp_from_name, FALSE); + // --- Define reply-to + if ($p_smtp_reply_address!='') + { + $mail->clearReplyTos(); + $mail->addReplyTo($p_smtp_reply_address, $p_smtp_reply_name); + } + // --- Add recipient $mail->addAddress($p_recipient);