Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
5130b279
Commit
5130b279
authored
Oct 10, 2014
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
management/mail_log.py also include the previously rotated log file
parent
aac6e49b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
mail_log.py
management/mail_log.py
+7
-5
No files found.
management/mail_log.py
View file @
5130b279
#!/usr/bin/python3
#!/usr/bin/python3
import
re
import
re
,
os
.
path
import
dateutil.parser
import
dateutil.parser
import
mailconfig
import
mailconfig
...
@@ -16,9 +16,11 @@ def scan_mail_log(logger, env):
...
@@ -16,9 +16,11 @@ 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'
):
for
line
in
log
:
if
not
os
.
path
.
exists
(
fn
):
continue
scan_mail_log_line
(
line
.
strip
(),
collector
)
with
open
(
fn
)
as
log
:
for
line
in
log
:
scan_mail_log_line
(
line
.
strip
(),
collector
)
if
collector
[
"imap-logins"
]:
if
collector
[
"imap-logins"
]:
logger
.
add_heading
(
"Recent IMAP Logins"
)
logger
.
add_heading
(
"Recent IMAP Logins"
)
...
@@ -33,7 +35,7 @@ def scan_mail_log(logger, env):
...
@@ -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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment