mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-12-02 09:02:42 +02:00
Fixed issue with subdomain senders + added TO variable and allow new lines in text using \n
This commit is contained in:
parent
fd14c51f85
commit
d8e314db1a
@ -47,13 +47,15 @@ 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'];
|
||||||
$sender_address = $headers['X-Rspamd-From'];
|
$sender = $headers['X-Rspamd-From'];
|
||||||
$ip = $headers['X-Rspamd-Ip'];
|
$ip = $headers['X-Rspamd-Ip'];
|
||||||
$subject = $headers['X-Rspamd-Subject'];
|
$subject = $headers['X-Rspamd-Subject'];
|
||||||
$priority = 0;
|
$priority = 0;
|
||||||
|
$to = $json_body->header_to[0];
|
||||||
|
|
||||||
$symbols_array = json_decode($headers['X-Rspamd-Symbols'], true);
|
$symbols_array = json_decode($headers['X-Rspamd-Symbols'], true);
|
||||||
if (is_array($symbols_array)) {
|
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];
|
if (preg_match('/(?<name>.*?)<(?<address>.*?)>/i', $sender_address, $matches)) {
|
||||||
$sender_name = trim(str_replace('<' . $sender_address . '>', '', $sender));
|
$sender_address = $matches['address'];
|
||||||
|
$sender_name = trim(trim($matches['name']), '"\' ');
|
||||||
|
}
|
||||||
|
|
||||||
$rcpt_final_mailboxes = array();
|
$rcpt_final_mailboxes = array();
|
||||||
|
|
||||||
@ -213,18 +218,18 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!empty($senders)) {
|
if (!empty($senders)) {
|
||||||
if (in_array($sender_address, $senders)) {
|
if (in_array($sender, $senders)) {
|
||||||
$sender_validated = true;
|
$sender_validated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($senders_regex) && $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;
|
$sender_validated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($sender_validated === false) {
|
if ($sender_validated === false) {
|
||||||
error_log("NOTIFY: pushover pipe: skipping unwanted sender " . $sender_address);
|
error_log("NOTIFY: pushover pipe: skipping unwanted sender " . $sender);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($attributes['only_x_prio'] == "1" && $priority == 0) {
|
if ($attributes['only_x_prio'] == "1" && $priority == 0) {
|
||||||
@ -234,9 +239,9 @@ 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}', '{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,
|
"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"
|
"sound" => $attributes['sound'] ?? "pushover"
|
||||||
);
|
);
|
||||||
if ($attributes['evaluate_x_prio'] == "1" && $priority == 1) {
|
if ($attributes['evaluate_x_prio'] == "1" && $priority == 1) {
|
||||||
|
@ -275,7 +275,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<p class="help-block">{{ lang.user.pushover_info|format(mailbox)|raw }}</p>
|
<p class="help-block">{{ lang.user.pushover_info|format(mailbox)|raw }}</p>
|
||||||
<p class="help-block">{{ lang.edit.pushover_vars|raw }}: <code>{SUBJECT}</code>, <code>{SENDER}</code>, <code>{SENDER_ADDRESS}</code>, <code>{SENDER_NAME}</code></p>
|
<p class="help-block">{{ lang.edit.pushover_vars|raw }}: <code>{SUBJECT}</code>, <code>{SENDER}</code>, <code>{SENDER_ADDRESS}</code>, <code>{SENDER_NAME}</code>, <code>{TO}</code></p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<p class="help-block">{{ lang.user.pushover_info|format(mailcow_cc_username)|raw }}</p>
|
<p class="help-block">{{ lang.user.pushover_info|format(mailcow_cc_username)|raw }}</p>
|
||||||
<p class="help-block">{{ lang.user.pushover_vars|raw }}: <code>{SUBJECT}</code>, <code>{SENDER}</code>, <code>{SENDER_ADDRESS}</code>, <code>{SENDER_NAME}</code></p>
|
<p class="help-block">{{ lang.edit.pushover_vars|raw }}: <code>{SUBJECT}</code>, <code>{SENDER}</code>, <code>{SENDER_ADDRESS}</code>, <code>{SENDER_NAME}</code>, <code>{TO}</code></p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
Loading…
Reference in New Issue
Block a user