瀏覽代碼

[Dovecot] removed non-ascii chars from 'from' field before send

zekeriya 6 年之前
父節點
當前提交
96042bdab8
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      data/Dockerfiles/dovecot/quarantine_notify.py

+ 3 - 1
data/Dockerfiles/dovecot/quarantine_notify.py

@@ -74,7 +74,9 @@ def notify_rcpt(rcpt, msg_count, quarantine_acl):
       server = smtplib.SMTP('postfix', 590, 'quarantine')
       server.ehlo()
       msg = MIMEMultipart('alternative')
-      msg['From'] = r.get('Q_SENDER') or "quarantine@localhost"
+      msg_from = r.get('Q_SENDER') or "quarantine@localhost"
+      # Remove non-ascii chars from field
+      msg['From'] = ''.join([i if ord(i) < 128 else '' for i in msg_from])
       msg['Subject'] = r.get('Q_SUBJ') or "Spam Quarantine Notification"
       msg['Date'] = formatdate(localtime = True)
       text_part = MIMEText(text, 'plain', 'utf-8')