git subrepo commit (merge) mailcow/src/mailcow-dockerized
subrepo: subdir: "mailcow/src/mailcow-dockerized"
merged: "02ae5285"
upstream: origin: "https://github.com/mailcow/mailcow-dockerized.git"
branch: "master"
commit: "649a5c01"
git-subrepo: version: "0.4.3"
origin: "???"
commit: "???"
Change-Id: I870ad468fba026cc5abf3c5699ed1e12ff28b32b
diff --git a/mailcow/src/mailcow-dockerized/data/Dockerfiles/dovecot/quota_notify.py b/mailcow/src/mailcow-dockerized/data/Dockerfiles/dovecot/quota_notify.py
index fdfda30..2d7361b 100755
--- a/mailcow/src/mailcow-dockerized/data/Dockerfiles/dovecot/quota_notify.py
+++ b/mailcow/src/mailcow-dockerized/data/Dockerfiles/dovecot/quota_notify.py
@@ -9,6 +9,7 @@
from jinja2 import Template
import redis
import time
+import json
import sys
import html2text
from subprocess import Popen, PIPE, STDOUT
@@ -57,6 +58,27 @@
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, 'quotanotification')
+ 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)