mirror of
https://github.com/moudsen/mailGraph
synced 2025-01-30 20:01:38 +01:00
v2.14 - Adding ability to set 'From' address details in configuration
This commit is contained in:
parent
6da6da77fb
commit
8269195795
@ -27,7 +27,7 @@ _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)
|
||||
- `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")
|
||||
|
||||
## mailGraph v2.13 release ##
|
||||
|
@ -1,6 +1,5 @@
|
||||
{
|
||||
"script_baseurl": "https:\/\/mydomain.com\/",
|
||||
"cli_triggerId": 0,
|
||||
"cli_eventId": 0,
|
||||
"cli_duration": 0,
|
||||
"cli_recipient": "recipient@mydomain.com",
|
||||
@ -14,7 +13,6 @@
|
||||
"zabbix_user_pwd": "astrongpassword",
|
||||
"zabbix_api_user": "alogicalusername",
|
||||
"zabbix_api_pwd": "astrongpassword",
|
||||
"mail_from": "sender@mydomain.com",
|
||||
"subject": "{{ HOST_NAME|raw }}: ({{ EVENT_SEVERITY }}) {{ EVENT_NAME|raw }}",
|
||||
"smtp_server": "localhost",
|
||||
"smtp_port": 25,
|
||||
|
@ -1,7 +1,5 @@
|
||||
{
|
||||
"script_baseurl": "https:\/\/mydomain.com\/",
|
||||
"cli_itemId": 0,
|
||||
"cli_triggerId": 0,
|
||||
"cli_eventId": 0,
|
||||
"cli_duration": 0,
|
||||
"cli_recipient": "recipient@mydomain.com",
|
||||
@ -15,12 +13,13 @@
|
||||
"zabbix_user_pwd": "astrongpassword",
|
||||
"zabbix_api_user": "alogicalusername",
|
||||
"zabbix_api_pwd": "astrongpassword",
|
||||
"mail_from": "sender@mydomain.com",
|
||||
"subject": "{{ HOST_NAME|raw }}: ({{ EVENT_SEVERITY }}) {{ EVENT_NAME|raw }}",
|
||||
"smtp_server": "localhost",
|
||||
"smtp_port": 25,
|
||||
"smtp_transport": "none",
|
||||
"smtp_strict": "yes",
|
||||
"smtp_from_address": "mailgraph@mydomain.com",
|
||||
"smtp_from_name": "mailGraph",
|
||||
"graph_match": "any",
|
||||
"periods": "10m,4h,2d,7d",
|
||||
"periods_headers": "Last 10 minutes,Last 4 hours,Last 2 days,Last 7 days",
|
||||
|
@ -53,7 +53,7 @@
|
||||
// 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 details in configuration
|
||||
// 2.14 2023/07/10 - Mark Oudsen - Adding ability to set 'From' address in configuration
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// (C) M.J.Oudsen, mark.oudsen@puzzl.nl
|
||||
@ -599,6 +599,15 @@
|
||||
$p_smtp_from_name = 'mailGraph';
|
||||
if (isset($config['smtp_from_name'])) { $p_smtp_from_name = $config['smtp_from_name']; }
|
||||
|
||||
// >>> Backwards compatibility but smtp_from_address is leading (<v2.14)
|
||||
$mailFrom = '';
|
||||
if (isset($config['mail_from'])) { $mailFrom = $config['mail_from']; }
|
||||
|
||||
if (($p_smtp_from_address=='') && ($mailFrom!=''))
|
||||
{
|
||||
$p_smtp_from_address = $mailFrom;
|
||||
}
|
||||
|
||||
$p_graph_match = 'any';
|
||||
if ((isset($config['graph_match'])) && ($config['graph_match']=='exact')) { $p_graph_match = 'exact'; }
|
||||
|
||||
@ -635,9 +644,6 @@
|
||||
$z_api_pass = $config['zabbix_api_pwd'];
|
||||
}
|
||||
|
||||
// Mail sender
|
||||
$mailFrom = $config['mail_from'];
|
||||
|
||||
// Derived variables - do not change!
|
||||
$z_server = $p_URL; // Zabbix server URL from config
|
||||
$z_url_api = $z_server ."api_jsonrpc.php"; // Zabbix API URL
|
||||
@ -1419,15 +1425,8 @@
|
||||
}
|
||||
|
||||
// --- Define from
|
||||
if ($p_smtp_from_address!='')
|
||||
{
|
||||
$mail->Sender = $p_smtp_from_address;
|
||||
$mail->SetFrom($p_smtp_from_address, $p_smtp_from_name, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mail->setFrom($mailFrom, $p_smtp_from_name);
|
||||
}
|
||||
$mail->Sender = $p_smtp_from_address;
|
||||
$mail->SetFrom($p_smtp_from_address, $p_smtp_from_name, FALSE);
|
||||
|
||||
// --- Add recipient
|
||||
$mail->addAddress($p_recipient);
|
||||
|
Loading…
x
Reference in New Issue
Block a user