diff --git a/data/conf/rspamd/meta_exporter/pushover.php b/data/conf/rspamd/meta_exporter/pushover.php index ffc826a7..2f2206ea 100644 --- a/data/conf/rspamd/meta_exporter/pushover.php +++ b/data/conf/rspamd/meta_exporter/pushover.php @@ -47,13 +47,15 @@ if (!function_exists('getallheaders')) { } $headers = getallheaders(); +$json_body = json_decode(file_get_contents('php://input')); -$qid = $headers['X-Rspamd-Qid']; -$rcpts = $headers['X-Rspamd-Rcpt']; -$sender_address = $headers['X-Rspamd-From']; -$ip = $headers['X-Rspamd-Ip']; -$subject = $headers['X-Rspamd-Subject']; -$priority = 0; +$qid = $headers['X-Rspamd-Qid']; +$rcpts = $headers['X-Rspamd-Rcpt']; +$sender = $headers['X-Rspamd-From']; +$ip = $headers['X-Rspamd-Ip']; +$subject = $headers['X-Rspamd-Subject']; +$priority = 0; +$to = $json_body->header_to[0]; $symbols_array = json_decode($headers['X-Rspamd-Symbols'], true); if (is_array($symbols_array)) { @@ -65,10 +67,13 @@ if (is_array($symbols_array)) { } } -$json = json_decode(file_get_contents('php://input')); +$sender_address = $json_body->header_from[0]; +$sender_name = '-'; -$sender = $json->header_from[0]; -$sender_name = trim(str_replace('<' . $sender_address . '>', '', $sender)); +if (preg_match('/(?.*?)<(?
.*?)>/i', $sender_address, $matches)) { + $sender_address = $matches['address']; + $sender_name = trim(trim($matches['name']), '"\' '); +} $rcpt_final_mailboxes = array(); @@ -213,18 +218,18 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) { } else { if (!empty($senders)) { - if (in_array($sender_address, $senders)) { + if (in_array($sender, $senders)) { $sender_validated = true; } } if (!empty($senders_regex) && $sender_validated !== true) { - if (preg_match($senders_regex, $sender_address)) { + if (preg_match($senders_regex, $sender)) { $sender_validated = true; } } } if ($sender_validated === false) { - error_log("NOTIFY: pushover pipe: skipping unwanted sender " . $sender_address); + error_log("NOTIFY: pushover pipe: skipping unwanted sender " . $sender); continue; } if ($attributes['only_x_prio'] == "1" && $priority == 0) { @@ -234,9 +239,9 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) { $post_fields = array( "token" => $api_data['token'], "user" => $api_data['key'], - "title" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}'), array($subject, $sender, $sender_name, $sender_address), $title)), + "title" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO}'), array($subject, $sender, $sender_name, $sender_address, $to), $title)), "priority" => $priority, - "message" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}'), array($subject, $sender, $sender_name, $sender_address), $text)), + "message" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO}', '\n'), array($subject, $sender, $sender_name, $sender_address, $to, PHP_EOL), $text)), "sound" => $attributes['sound'] ?? "pushover" ); if ($attributes['evaluate_x_prio'] == "1" && $priority == 1) { diff --git a/data/web/templates/edit/mailbox.twig b/data/web/templates/edit/mailbox.twig index f0154584..f2e80c96 100644 --- a/data/web/templates/edit/mailbox.twig +++ b/data/web/templates/edit/mailbox.twig @@ -275,7 +275,7 @@

{{ lang.user.pushover_info|format(mailbox)|raw }}

-

{{ lang.edit.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}

+

{{ lang.edit.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}, {TO}

diff --git a/data/web/templates/user/Pushover.twig b/data/web/templates/user/Pushover.twig index a1867a8b..ea1d2c16 100644 --- a/data/web/templates/user/Pushover.twig +++ b/data/web/templates/user/Pushover.twig @@ -9,7 +9,7 @@

{{ lang.user.pushover_info|format(mailcow_cc_username)|raw }}

-

{{ lang.user.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}

+

{{ lang.edit.pushover_vars|raw }}: {SUBJECT}, {SENDER}, {SENDER_ADDRESS}, {SENDER_NAME}, {TO}