[Dovecot] Fixed quarantine_notify.py json decode error
parent
b9e7d12a5e
commit
8af9b5b6d1
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import smtplib
|
import smtplib
|
||||||
import os
|
import os
|
||||||
|
@ -82,7 +83,7 @@ def notify_rcpt(rcpt, msg_count, quarantine_acl):
|
||||||
msg.attach(html_part)
|
msg.attach(html_part)
|
||||||
msg['To'] = str(rcpt)
|
msg['To'] = str(rcpt)
|
||||||
text = msg.as_string()
|
text = msg.as_string()
|
||||||
server.sendmail(msg['From'].encode("ascii", errors="ignore"), msg['To'], text)
|
server.sendmail(msg['From'], msg['To'], text)
|
||||||
server.quit()
|
server.quit()
|
||||||
for res in meta_query:
|
for res in meta_query:
|
||||||
query_mysql('UPDATE quarantine SET notified = 1 WHERE id = "%d"' % (res['id']), update = True)
|
query_mysql('UPDATE quarantine SET notified = 1 WHERE id = "%d"' % (res['id']), update = True)
|
||||||
|
@ -107,7 +108,8 @@ for record in records:
|
||||||
print('Could not determine last notification for %s, assuming never' % (record['rcpt']))
|
print('Could not determine last notification for %s, assuming never' % (record['rcpt']))
|
||||||
last_notification = 0
|
last_notification = 0
|
||||||
attrs_json = query_mysql('SELECT attributes FROM mailbox WHERE username = "%s"' % (record['rcpt']))
|
attrs_json = query_mysql('SELECT attributes FROM mailbox WHERE username = "%s"' % (record['rcpt']))
|
||||||
attrs = json.loads(str(attrs_json[0]['attributes']))
|
print("\n\n\n\n",attrs_json,"\n\n\n\n")
|
||||||
|
attrs = json.loads(str(attrs_json[0]['attributes'].decode('utf-8')))
|
||||||
if attrs['quarantine_notification'] not in ('hourly', 'daily', 'weekly', 'never'):
|
if attrs['quarantine_notification'] not in ('hourly', 'daily', 'weekly', 'never'):
|
||||||
print('Abnormal quarantine_notification value')
|
print('Abnormal quarantine_notification value')
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue