Added SENDER_ADDRESS and SENDER_NAME as variables for messages

This commit is contained in:
bluewalk 2022-11-17 14:30:06 +01:00 committed by DerLinkman
parent fbc33da734
commit e82f3b3975
4 changed files with 12 additions and 6 deletions

View File

@ -16,8 +16,7 @@ rules {
backend = "http";
url = "http://nginx:9081/pushover.php";
selector = "mailcow_rcpt";
# Only return msgid, do not parse the full message
formatter = "msgid";
formatter = "json";
meta_headers = true;
}
}

View File

@ -65,6 +65,13 @@ if (is_array($symbols_array)) {
}
}
$json = json_decode(file_get_contents('php://input'));
$sender_address = $json->header_from ;
if (preg_match('/[a-zA-Z0-9.!#$%&*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)/i', $sender, $matches))
$sender_address = $matches[0];
$sender_name = trim(str_replace('<' . $email . '>', '', $from));
$rcpt_final_mailboxes = array();
// Loop through all rcpts
@ -229,9 +236,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}'), array($subject, $sender), $title)),
"title" => sprintf("%s", str_replace(array('{SUBJECT}', '{SENDER}', '{SENDER_NAME}', '{SENDER_ADDRESS}'), array($subject, $sender, $sender_name, $sender_address), $title)),
"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}'), array($subject, $sender, $sender_name, $sender_address), $text))
);
if ($attributes['evaluate_x_prio'] == "1" && $priority == 1) {
$post_fields['expire'] = 600;

View File

@ -275,7 +275,7 @@
</div>
<div class="col-sm-10">
<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></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>
<div class="form-group">
<div class="row">
<div class="col-sm-6">

View File

@ -9,7 +9,7 @@
</div>
<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_vars|raw }}: <code>{SUBJECT}</code>, <code>{SENDER}</code></p>
<p class="help-block">{{ lang.user.pushover_vars|raw }}: <code>{SUBJECT}</code>, <code>{SENDER}</code>, <code>{SENDER_ADDRESS}</code>, <code>{SENDER_NAME}</p>
<div class="form-group">
<div class="row">
<div class="col-sm-6">