|
@@ -47,6 +47,7 @@ if (!function_exists('getallheaders')) {
|
|
}
|
|
}
|
|
|
|
|
|
$headers = getallheaders();
|
|
$headers = getallheaders();
|
|
|
|
+$json_body = json_decode(file_get_contents('php://input'));
|
|
|
|
|
|
$qid = $headers['X-Rspamd-Qid'];
|
|
$qid = $headers['X-Rspamd-Qid'];
|
|
$rcpts = $headers['X-Rspamd-Rcpt'];
|
|
$rcpts = $headers['X-Rspamd-Rcpt'];
|
|
@@ -65,6 +66,20 @@ if (is_array($symbols_array)) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+$sender_address = $json_body->header_from[0];
|
|
|
|
+$sender_name = '-';
|
|
|
|
+if (preg_match('/(?<name>.*?)<(?<address>.*?)>/i', $sender_address, $matches)) {
|
|
|
|
+ $sender_address = $matches['address'];
|
|
|
|
+ $sender_name = trim($matches['name'], '"\' ');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+$to_address = $json_body->header_to[0];
|
|
|
|
+$to_name = '-';
|
|
|
|
+if (preg_match('/(?<name>.*?)<(?<address>.*?)>/i', $to_address, $matches)) {
|
|
|
|
+ $to_address = $matches['address'];
|
|
|
|
+ $to_name = trim($matches['name'], '"\' ');
|
|
|
|
+}
|
|
|
|
+
|
|
$rcpt_final_mailboxes = array();
|
|
$rcpt_final_mailboxes = array();
|
|
|
|
|
|
// Loop through all rcpts
|
|
// Loop through all rcpts
|
|
@@ -229,9 +244,16 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) {
|
|
$post_fields = array(
|
|
$post_fields = array(
|
|
"token" => $api_data['token'],
|
|
"token" => $api_data['token'],
|
|
"user" => $api_data['key'],
|
|
"user" => $api_data['key'],
|
|
- "title" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}'), array($subject, $sender), $title)),
|
|
|
|
|
|
+ "title" => sprintf("%s", str_replace(
|
|
|
|
+ array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO_NAME}', '{TO_ADDRESS}'),
|
|
|
|
+ array($subject, $sender, $sender_name, $sender_address, $to_name, $to_address), $title)
|
|
|
|
+ ),
|
|
"priority" => $priority,
|
|
"priority" => $priority,
|
|
- "message" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}'), array($subject, $sender), $text))
|
|
|
|
|
|
+ "message" => sprintf("%s", str_replace(
|
|
|
|
+ array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}', '{TO_NAME}', '{TO_ADDRESS}', '\n'),
|
|
|
|
+ array($subject, $sender, $sender_name, $sender_address, $to_name, $to_address, PHP_EOL), $text)
|
|
|
|
+ ),
|
|
|
|
+ "sound" => $attributes['sound'] ?? "pushover"
|
|
);
|
|
);
|
|
if ($attributes['evaluate_x_prio'] == "1" && $priority == 1) {
|
|
if ($attributes['evaluate_x_prio'] == "1" && $priority == 1) {
|
|
$post_fields['expire'] = 600;
|
|
$post_fields['expire'] = 600;
|