From beda649ecfaa0af0b21d873f4f24f06b0e7eedd6 Mon Sep 17 00:00:00 2001 From: andryyy Date: Sun, 23 May 2021 09:49:36 +0200 Subject: [PATCH] [Dovecot] Quota notifications: Allow to send to external address (BCC via mailcow UI) --- data/Dockerfiles/dovecot/quota_notify.py | 24 ++++++++++++++++++- .../css/build/006-footable.bootstrap.min.css | 6 ++--- data/web/css/build/008-mailcow.css | 6 +++++ data/web/debug.php | 2 +- data/web/inc/header.inc.php | 4 ++-- data/web/js/site/mailbox.js | 2 +- 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/data/Dockerfiles/dovecot/quota_notify.py b/data/Dockerfiles/dovecot/quota_notify.py index fdfda304..419f80d4 100755 --- a/data/Dockerfiles/dovecot/quota_notify.py +++ b/data/Dockerfiles/dovecot/quota_notify.py @@ -9,6 +9,7 @@ import jinja2 from jinja2 import Template import redis import time +import json import sys import html2text from subprocess import Popen, PIPE, STDOUT @@ -57,6 +58,27 @@ try: p = Popen(['/usr/lib/dovecot/dovecot-lda', '-d', username, '-o', '"plugin/quota=maildir:User quota:noenforcing"'], stdout=PIPE, stdin=PIPE, stderr=STDOUT) p.communicate(input=bytes(msg.as_string(), 'utf-8')) + domain = username.split("@")[-1] + if domain and r.hget('QW_BCC', domain): + bcc_data = json.loads(r.hget('QW_BCC', domain)) + bcc_rcpts = bcc_data['bcc_rcpts'] + if bcc_data['active'] == 1: + for rcpt in bcc_rcpts: + msg = MIMEMultipart('alternative') + msg['From'] = username + subject = r.get('QW_SUBJ') or "Quota warning" + msg['Subject'] = subject + ' (' + username + ')' + msg['Date'] = formatdate(localtime = True) + text_part = MIMEText(text, 'plain', 'utf-8') + html_part = MIMEText(html, 'html', 'utf-8') + msg.attach(text_part) + msg.attach(html_part) + msg['To'] = rcpt + server = smtplib.SMTP('postfix', 588, 'quarantine') + server.ehlo() + server.sendmail(msg['From'], str(rcpt), msg.as_string()) + server.quit() + except Exception as ex: print('Failed to send quota notification: %s' % (ex)) sys.exit(1) @@ -69,4 +91,4 @@ except: try: sys.stderr.close() except: - pass + pass \ No newline at end of file diff --git a/data/web/css/build/006-footable.bootstrap.min.css b/data/web/css/build/006-footable.bootstrap.min.css index 2a533ab1..670eab25 100644 --- a/data/web/css/build/006-footable.bootstrap.min.css +++ b/data/web/css/build/006-footable.bootstrap.min.css @@ -104,7 +104,7 @@ table.footable > tbody > tr.footable-empty > th { } .fooicon { position: relative; - top: 1px; + top: 0px; display: inline-block; font-family: "bootstrap-icons" !important; font-style: normal; @@ -123,10 +123,10 @@ table.footable > tbody > tr.footable-empty > th { content: "\f130"; } .fooicon-plus:before { - content: "\f64d"; + content: "\f4fc"; } .fooicon-minus:before { - content: "\f63b"; + content: "\f2e8"; } .fooicon-search:before { content: "\f52a"; diff --git a/data/web/css/build/008-mailcow.css b/data/web/css/build/008-mailcow.css index 04212d40..8bd703fd 100644 --- a/data/web/css/build/008-mailcow.css +++ b/data/web/css/build/008-mailcow.css @@ -230,3 +230,9 @@ table.footable>tbody>tr.footable-empty>td { font-style:italic; font-size: 1rem; } +.navbar-nav > li { + font-size: 1rem !important; +} +.dropdown-menu > li > a { + font-size: 1rem !important; +} \ No newline at end of file diff --git a/data/web/debug.php b/data/web/debug.php index 6e7c9889..a935ea20 100644 --- a/data/web/debug.php +++ b/data/web/debug.php @@ -83,7 +83,7 @@ $xmpp_status = xmpp_control('status');

:

:

:

-

:

+

:

diff --git a/data/web/inc/header.inc.php b/data/web/inc/header.inc.php index fdcbb078..794c365c 100644 --- a/data/web/inc/header.inc.php +++ b/data/web/inc/header.inc.php @@ -127,9 +127,9 @@ -
  • +
  • -
  • ()
  • +
  • ()
  • [ slave ]
  • diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index 3b2c948f..6397bb98 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -291,7 +291,7 @@ jQuery(function($){ else { item.action += ' ' + lang.edit + ''; } - item.action += ' DNS'; + item.action += ' DNS'; if (item.backupmx == 1) { if (item.relay_unknown_only == 1) { item.domain_name = '
    Relay Non-Local
    ' + item.domain_name;