From c11a9d3a8003c5fdf60afbfd6a2e9efc9b40666a Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 8 Jul 2018 22:01:01 -0400 Subject: [PATCH] Update email_functions --- inc/email_functions.inc.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/inc/email_functions.inc.php b/inc/email_functions.inc.php index 62d93059..bf5c09ec 100644 --- a/inc/email_functions.inc.php +++ b/inc/email_functions.inc.php @@ -1010,5 +1010,21 @@ function hesk_generateMessageID() { $id = uniqid('', true); } - return '<' . $id . '.' . gmdate('YmdHis') . '@' . $_SERVER['SERVER_NAME'] . '>'; + // If run from CLI, set the Hesk URL as host name + if (isset($_SERVER['SERVER_NAME'])) { + $host = $_SERVER['SERVER_NAME']; + } else { + global $hesk_settings; + + $parts = parse_url($hesk_settings['hesk_url']); + + if (empty($parts['host'])) { + $host = gethostname(); + $host = str_replace('>', '', $host); + } else { + $host = $parts['host']; + } + } + + return '<' . $id . '.' . gmdate('YmdHis') . '@' . $host . '>'; } // END hesk_generateMessageID()