mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-12-14 10:52:49 +02:00
Merge pull request #2569 from Howaner/quarantine-domain-alias
Added domain alias handling to quarantine mails and added recipients row to quarantine mail display
This commit is contained in:
commit
48984270dd
@ -131,6 +131,14 @@ foreach (json_decode($rcpts, true) as $rcpt) {
|
||||
));
|
||||
$gotos = $stmt->fetch(PDO::FETCH_ASSOC)['goto'];
|
||||
}
|
||||
if (empty($gotos)) {
|
||||
$stmt = $pdo->prepare("SELECT `target_domain` FROM `alias_domain` WHERE `alias_domain` = :rcpt AND `active` = '1'");
|
||||
$stmt->execute(array(':rcpt' => $parsed_rcpt['domain']));
|
||||
$goto_branch = $stmt->fetch(PDO::FETCH_ASSOC)['target_domain'];
|
||||
if ($goto_branch) {
|
||||
$gotos = $parsed_rcpt['local'] . '@' . $goto_branch;
|
||||
}
|
||||
}
|
||||
$gotos_array = explode(',', $gotos);
|
||||
|
||||
$loop_c = 0;
|
||||
@ -159,8 +167,18 @@ foreach (json_decode($rcpts, true) as $rcpt) {
|
||||
$stmt = $pdo->prepare("SELECT `goto` FROM `alias` WHERE `address` = :goto AND `active` = '1'");
|
||||
$stmt->execute(array(':goto' => $goto));
|
||||
$goto_branch = $stmt->fetch(PDO::FETCH_ASSOC)['goto'];
|
||||
error_log("QUARANTINE: quarantine pipe: goto address " . $goto . " is a alias branch for " . $goto_branch);
|
||||
$goto_branch_array = explode(',', $goto_branch);
|
||||
if ($goto_branch) {
|
||||
error_log("QUARANTINE: quarantine pipe: goto address " . $goto . " is a alias branch for " . $goto_branch);
|
||||
$goto_branch_array = explode(',', $goto_branch);
|
||||
} else {
|
||||
$stmt = $pdo->prepare("SELECT `target_domain` FROM `alias_domain` WHERE `alias_domain` = :domain AND `active` AND '1'");
|
||||
$stmt->execute(array(':domain' => $parsed_goto['domain']));
|
||||
$goto_branch = $stmt->fetch(PDO::FETCH_ASSOC)['target_domain'];
|
||||
if ($goto_branch) {
|
||||
error_log("QUARANTINE: quarantine pipe: goto domain " . $parsed_gto['domain'] . " is a domain alias branch for " . $goto_branch);
|
||||
$goto_branch_array = array($parsed_gto['local'] . '@' . $goto_branch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// goto item was processed, unset
|
||||
|
@ -48,4 +48,12 @@ table.footable>tbody>tr.footable-empty>td {
|
||||
background-color: #d4d4d4;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
span.mail-address-item {
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ccc;
|
||||
padding: 2px 7px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
@ -3,8 +3,9 @@ session_start();
|
||||
header("Content-Type: application/json");
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
|
||||
if (!isset($_SESSION['mailcow_cc_role'])) {
|
||||
exit();
|
||||
exit();
|
||||
}
|
||||
|
||||
function rrmdir($src) {
|
||||
$dir = opendir($src);
|
||||
while(false !== ( $file = readdir($dir)) ) {
|
||||
@ -21,6 +22,13 @@ function rrmdir($src) {
|
||||
closedir($dir);
|
||||
rmdir($src);
|
||||
}
|
||||
function addAddresses(&$list, $mail, $headerName) {
|
||||
$addresses = $mail->getAddresses($headerName);
|
||||
foreach ($addresses as $address) {
|
||||
$list[] = array('address' => $address['address'], 'type' => $headerName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['id']) && ctype_alnum($_GET['id'])) {
|
||||
$tmpdir = '/tmp/' . $_GET['id'] . '/';
|
||||
$mailc = quarantine('details', $_GET['id']);
|
||||
@ -36,6 +44,16 @@ if (!empty($_GET['id']) && ctype_alnum($_GET['id'])) {
|
||||
$html2text = new Html2Text\Html2Text();
|
||||
// Load msg to parser
|
||||
$mail_parser->setText($mailc['msg']);
|
||||
|
||||
// Get mail recipients
|
||||
{
|
||||
$recipientsList = array();
|
||||
addAddresses($recipientsList, $mail_parser, 'to');
|
||||
addAddresses($recipientsList, $mail_parser, 'cc');
|
||||
addAddresses($recipientsList, $mail_parser, 'bcc');
|
||||
$data['recipients'] = $recipientsList;
|
||||
}
|
||||
|
||||
// Get text/plain content
|
||||
$data['text_plain'] = $mail_parser->getMessageBody('text');
|
||||
// Get html content and convert to text
|
||||
|
@ -87,8 +87,17 @@ jQuery(function($){
|
||||
$('#qid_detail_text').text(data.text_plain);
|
||||
$('#qid_detail_text_from_html').text(data.text_html);
|
||||
|
||||
$('#qid_detail_recipients').html('');
|
||||
if (typeof data.recipients !== 'undefined') {
|
||||
$.each(data.recipients, function(index, value) {
|
||||
var elem = $('<span class="mail-address-item"></span>');
|
||||
elem.text(value.address + (value.type != 'to' ? (' (' + value.type.toUpperCase() + ')') : ''));
|
||||
$('#qid_detail_recipients').append(elem);
|
||||
});
|
||||
}
|
||||
|
||||
var qAtts = $("#qid_detail_atts");
|
||||
if (typeof data.attachments !== 'undefined') {
|
||||
qAtts = $("#qid_detail_atts");
|
||||
qAtts.text('');
|
||||
$.each(data.attachments, function(index, value) {
|
||||
qAtts.append(
|
||||
|
@ -498,6 +498,7 @@ $lang['quarantine']['show_item'] = "Mostrar";
|
||||
$lang['quarantine']['check_hash'] = "Comprovar el hash del fitxer a VT";
|
||||
$lang['quarantine']['qitem'] = "Element en quarantena";
|
||||
$lang['quarantine']['subj'] = "Assumpte";
|
||||
$lang['quarantine']['recipients'] = "Recipients";
|
||||
$lang['quarantine']['text_plain_content'] = "Contingut (text/plain)";
|
||||
$lang['quarantine']['text_from_html_content'] = "Contingut (a partir del HTML)";
|
||||
$lang['quarantine']['atts'] = "Adjunts";
|
||||
|
@ -712,6 +712,7 @@ $lang['quarantine']['show_item'] = "Zobrazit položku";
|
||||
$lang['quarantine']['check_hash'] = "Hledat hash @ VT souboru";
|
||||
$lang['quarantine']['qitem'] = "Položka v karanténě";
|
||||
$lang['quarantine']['subj'] = "Předmět";
|
||||
$lang['quarantine']['recipients'] = "Příjemci";
|
||||
$lang['quarantine']['text_plain_content'] = "Obsah (text/plain)";
|
||||
$lang['quarantine']['text_from_html_content'] = "Obsah (konvertované html)";
|
||||
$lang['quarantine']['atts'] = "Přílohy";
|
||||
|
@ -732,6 +732,7 @@ $lang['quarantine']['show_item'] = "Details";
|
||||
$lang['quarantine']['check_hash'] = "Checksumme auf VirusTotal suchen";
|
||||
$lang['quarantine']['qitem'] = "Quarantäneeintrag";
|
||||
$lang['quarantine']['subj'] = "Betreff";
|
||||
$lang['quarantine']['recipients'] = "Empfänger";
|
||||
$lang['quarantine']['text_plain_content'] = "Inhalt (text/plain)";
|
||||
$lang['quarantine']['text_from_html_content'] = "Inhalt (html, konvertiert)";
|
||||
$lang['quarantine']['atts'] = "Anhänge";
|
||||
|
@ -754,6 +754,7 @@ $lang['quarantine']['show_item'] = "Show item";
|
||||
$lang['quarantine']['check_hash'] = "Search file hash @ VT";
|
||||
$lang['quarantine']['qitem'] = "Quarantine item";
|
||||
$lang['quarantine']['subj'] = "Subject";
|
||||
$lang['quarantine']['recipients'] = "Recipients";
|
||||
$lang['quarantine']['text_plain_content'] = "Content (text/plain)";
|
||||
$lang['quarantine']['text_from_html_content'] = "Content (converted html)";
|
||||
$lang['quarantine']['atts'] = "Attachments";
|
||||
|
@ -494,6 +494,7 @@ $lang['quarantine']['show_item'] = "Parādīt vienumus";
|
||||
$lang['quarantine']['check_hash'] = "Meklēt faila hašu @ VT";
|
||||
$lang['quarantine']['qitem'] = "Karantīnas vienumi";
|
||||
$lang['quarantine']['subj'] = "Priekšmets";
|
||||
$lang['quarantine']['recipients'] = "Adresāts";
|
||||
$lang['quarantine']['text_plain_content'] = "Saturs (teksts/vienkāršs)";
|
||||
$lang['quarantine']['text_from_html_content'] = "Saturs (konvertēts html)";
|
||||
$lang['quarantine']['atts'] = "Pielikumi";
|
||||
|
@ -731,6 +731,7 @@ $lang['quarantine']['show_item'] = "Laat item zien";
|
||||
$lang['quarantine']['check_hash'] = "Zoek bestandshash op in VT";
|
||||
$lang['quarantine']['qitem'] = "Quarantaine-item";
|
||||
$lang['quarantine']['subj'] = "Onderwerp";
|
||||
$lang['quarantine']['recipients'] = "Ontvangers";
|
||||
$lang['quarantine']['text_plain_content'] = "Inhoud (tekst)";
|
||||
$lang['quarantine']['text_from_html_content'] = "Inhoud (geconverteerde html)";
|
||||
$lang['quarantine']['atts'] = "Bijlagen";
|
||||
|
@ -17,6 +17,10 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
|
||||
<label for="qid_detail_subj"><h4><?=$lang['quarantine']['subj'];?>:</h4></label>
|
||||
<p id="qid_detail_subj"></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="qid_detail_recipients"><h4><?=$lang['quarantine']['recipients'];?>:</h4></label>
|
||||
<p id="qid_detail_recipients"></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="qid_detail_text"><h4><?=$lang['quarantine']['text_plain_content'];?>:</h4></label>
|
||||
<pre id="qid_detail_text"></pre>
|
||||
|
Loading…
Reference in New Issue
Block a user