mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-22 02:17:26 +00:00
management/mail_log.py also include the previously rotated log file
This commit is contained in:
parent
aac6e49b94
commit
5130b279d8
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import re
|
import re, os.path
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
|
||||||
import mailconfig
|
import mailconfig
|
||||||
@ -16,7 +16,9 @@ def scan_mail_log(logger, env):
|
|||||||
|
|
||||||
collector["real_mail_addresses"] = set(mailconfig.get_mail_users(env)) | set(alias[0] for alias in mailconfig.get_mail_aliases(env))
|
collector["real_mail_addresses"] = set(mailconfig.get_mail_users(env)) | set(alias[0] for alias in mailconfig.get_mail_aliases(env))
|
||||||
|
|
||||||
with open("/var/log/mail.log") as log:
|
for fn in ('/var/log/mail.log.1', '/var/log/mail.log'):
|
||||||
|
if not os.path.exists(fn): continue
|
||||||
|
with open(fn) as log:
|
||||||
for line in log:
|
for line in log:
|
||||||
scan_mail_log_line(line.strip(), collector)
|
scan_mail_log_line(line.strip(), collector)
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ def scan_mail_log(logger, env):
|
|||||||
logger.print_line("recipient" + "\t" + "received" + "\t" + "sender" + "\t" + "delivered")
|
logger.print_line("recipient" + "\t" + "received" + "\t" + "sender" + "\t" + "delivered")
|
||||||
for recipient in utils.sort_email_addresses(collector["postgrey"], env):
|
for recipient in utils.sort_email_addresses(collector["postgrey"], env):
|
||||||
for (client_address, sender), (first_date, delivered_date) in sorted(collector["postgrey"][recipient].items(), key = lambda kv : kv[1][0]):
|
for (client_address, sender), (first_date, delivered_date) in sorted(collector["postgrey"][recipient].items(), key = lambda kv : kv[1][0]):
|
||||||
logger.print_line(recipient + "\t" + str(first_date) + "\t" + sender + "\t" + (("delivered " + str(delivered_date)) if delivered_date else "no retry"))
|
logger.print_line(recipient + "\t" + str(first_date) + "\t" + sender + "\t" + (("delivered " + str(delivered_date)) if delivered_date else "no retry yet"))
|
||||||
|
|
||||||
if collector["rejected-mail"]:
|
if collector["rejected-mail"]:
|
||||||
logger.add_heading("Rejected Mail")
|
logger.add_heading("Rejected Mail")
|
||||||
|
Loading…
Reference in New Issue
Block a user