v2.14 - Adding ability to set 'From' and 'Reply-to' address details in configuration

This commit is contained in:
Mark Oudsen 2023-07-10 14:32:47 +02:00
parent 8269195795
commit 0cd169a9d2
4 changed files with 26 additions and 2 deletions

View File

@ -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)_

View File

@ -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",

View File

@ -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",

View File

@ -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 (<v2.14)
$mailFrom = '';
if (isset($config['mail_from'])) { $mailFrom = $config['mail_from']; }
@ -1387,6 +1394,7 @@
$mailData['TRIGGER_URL'] = $z_server.'triggers.php?form=update&triggerid='.$mailData['TRIGGER_ID'].'&context=host';
$mailData['ITEM_URL'] = $z_server.'items.php?form=update&hostid='.$mailData['HOST_ID'].'&itemid='.$mailData['ITEM_ID'].'&context=host';
$mailData['HOST_URL'] = $z_server.'hosts.php?form=update&hostid='.$mailData['HOST_ID'];
$mailData['ACK_URL'] = $z_server.'zabbix.php?action=popup&popup_action=acknowledge.edit&eventids[]='.$mailData['EVENT_ID'];
$mailData['EVENTDETAILS_URL'] = $z_server.'tr_events.php?triggerid='.$mailData['TRIGGER_ID'].'&eventid='.$mailData['EVENT_ID'];
$mailData['EVENT_DURATION'] = $p_duration;
@ -1428,6 +1436,13 @@
$mail->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);