mirror of
https://github.com/moudsen/mailGraph
synced 2025-01-31 04:11:39 +01:00
Added ability to specify SMTP username/password (v1.28)
This commit is contained in:
parent
634134b423
commit
1278d43acb
@ -35,6 +35,7 @@
|
|||||||
// Suppressing Zabbix username-password in log
|
// Suppressing Zabbix username-password in log
|
||||||
// 1.27 2021/03/19 - Mark Oudsen - Added ability to define "mailGraph.screen" tag to embed graphs from
|
// 1.27 2021/03/19 - Mark Oudsen - Added ability to define "mailGraph.screen" tag to embed graphs from
|
||||||
// Added PHP informational and warnings to log for easier debug/spotting
|
// Added PHP informational and warnings to log for easier debug/spotting
|
||||||
|
// 1.28 2021/03/24 - Mark Oudsen - Added ability to specify username/password for TLS/SSL
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// (C) M.J.Oudsen, mark.oudsen@puzzl.nl
|
// (C) M.J.Oudsen, mark.oudsen@puzzl.nl
|
||||||
@ -57,7 +58,7 @@
|
|||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
|
|
||||||
$cVersion = 'v1.27';
|
$cVersion = 'v1.28';
|
||||||
$cCRLF = chr(10).chr(13);
|
$cCRLF = chr(10).chr(13);
|
||||||
$maskDateTime = 'Y-m-d H:i:s';
|
$maskDateTime = 'Y-m-d H:i:s';
|
||||||
$maxGraphs = 4;
|
$maxGraphs = 4;
|
||||||
@ -65,7 +66,7 @@
|
|||||||
// DEBUG SETTINGS
|
// DEBUG SETTINGS
|
||||||
// -- Should be FALSE for production level use
|
// -- Should be FALSE for production level use
|
||||||
|
|
||||||
$cDebug = FALSE; // Extended debug logging mode
|
$cDebug = TRUE; // Extended debug logging mode
|
||||||
$cDebugMail = FALSE; // If TRUE, includes log in the mail message (html and plain text attachments)
|
$cDebugMail = FALSE; // If TRUE, includes log in the mail message (html and plain text attachments)
|
||||||
$showLog = FALSE; // Display the log - !!! only use in combination with CLI mode !!!
|
$showLog = FALSE; // Display the log - !!! only use in combination with CLI mode !!!
|
||||||
|
|
||||||
@ -488,6 +489,12 @@
|
|||||||
$p_smtp_strict = 'yes';
|
$p_smtp_strict = 'yes';
|
||||||
if ((isset($config['smtp_strict'])) && ($config['smtp_strict']=='no')) { $p_smtp_strict = 'no'; }
|
if ((isset($config['smtp_strict'])) && ($config['smtp_strict']=='no')) { $p_smtp_strict = 'no'; }
|
||||||
|
|
||||||
|
$p_smtp_username = '';
|
||||||
|
if (isset($config['smtp_username'])) { $p_smtp_username = $config['smtp_username']; }
|
||||||
|
|
||||||
|
$p_smtp_password = '';
|
||||||
|
if (isset($config['smtp_password'])) { $p_smtp_password = $config['smtp_password']; }
|
||||||
|
|
||||||
$p_graph_match = 'any';
|
$p_graph_match = 'any';
|
||||||
if ((isset($config['graph_match'])) && ($config['graph_match']=='exact')) { $p_graph_match = 'exact'; }
|
if ((isset($config['graph_match'])) && ($config['graph_match']=='exact')) { $p_graph_match = 'exact'; }
|
||||||
|
|
||||||
@ -1242,11 +1249,18 @@
|
|||||||
$transport = (new Swift_SmtpTransport($p_smtp_server, $p_smtp_port));
|
$transport = (new Swift_SmtpTransport($p_smtp_server, $p_smtp_port));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Username/password?
|
||||||
|
|
||||||
|
if ($p_smtp_username!='') { $transport->setUsername($p_smtp_username); }
|
||||||
|
if ($p_smtp_password!='') { $transport->setPassword($p_smtp_password); }
|
||||||
|
|
||||||
|
// Start actual mail(er)
|
||||||
|
|
||||||
$mailer = new Swift_Mailer($transport);
|
$mailer = new Swift_Mailer($transport);
|
||||||
|
|
||||||
$message = (new Swift_Message());
|
$message = (new Swift_Message());
|
||||||
|
|
||||||
// Fetch mailer ID from this message (no Swift function available for it ...)
|
// --- Fetch mailer ID from this message (no Swift function available for it ...)
|
||||||
// --- "Message-ID: <...id...@swift.generated>"
|
// --- "Message-ID: <...id...@swift.generated>"
|
||||||
|
|
||||||
$content = $message->toString();
|
$content = $message->toString();
|
||||||
@ -1323,6 +1337,10 @@
|
|||||||
$response = array('messageId.mailGraph'=>$messageId);
|
$response = array('messageId.mailGraph'=>$messageId);
|
||||||
echo json_encode($response).$cCRLF;
|
echo json_encode($response).$cCRLF;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Wrap up //////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Store log?
|
// Store log?
|
||||||
|
|
||||||
if (($cDebug) || (isset($problemData['debug'])))
|
if (($cDebug) || (isset($problemData['debug'])))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user