Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
A. Schulze committed Dec 18, 2023
1 parent dd0c757 commit 5d6911a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ Now add a transport map entry. You may use the inline map:
transport_maps = inline:{sender@example=dmarc_dsn_processor}
```

Don't forget `postfix reload` and check your logs for warning/errors.

Create the working directory:

```sh
# install -d --owner nobody /path/to/data_dir
```

Finally, don't forget `postfix reload` and check your logs for warning/errors.

Now, wait until reports are sent (and get some dsn messages)

13 changes: 9 additions & 4 deletions build_postfix_discard_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ def handle_dsn(filename: str):

date = dsn_data['date']
orig_rcpt = dsn_data['orig_rcpt']
diag_code = dsn_data['diag_code']

if date is None:
date = 'unknown'

logging.debug("DEBUG: orig_rcpt=%s, domain=%s, date=%s", orig_rcpt, filename, date)
map_line = f"{orig_rcpt} DISCARD: report for {file} bounced {date} last time # {diag_code}"
map_line = f"{orig_rcpt} discard:report for {file} bounced {date} last time"
print(map_line)

# main
Expand All @@ -44,13 +43,19 @@ def handle_dsn(filename: str):
LOG_LEVEL = logging.DEBUG
logging.basicConfig(format='%(message)s', level=LOG_LEVEL)

DATA_DIR = os.getenv('DATA_DIR', './data')
# same 6 lines of code in dmarc_dsn_processor.py ...
# pylint: disable=duplicate-code
DATA_DIR = os.getenv('DATA_DIR', './dmarc_dsn_processor')
if os.path.isdir(DATA_DIR):
logging.debug('DEBUG: using %s', DATA_DIR)
else:
logging.error('ERROR: %s do not exist or is not a directory', DATA_DIR)
sys.exit(1)

if not os.path.exists(DATA_DIR + '/domains/'):
logging.error('ERROR: %s/domains do not exist, check DATA_DIR', DATA_DIR)
sys.exit(1)

MIN_AGE_IS_INT = True
MIN_AGE = os.getenv('MIN_AGE', '30')
try:
Expand All @@ -76,7 +81,7 @@ def handle_dsn(filename: str):

TODAY = datetime.datetime.today()

os.chdir(DATA_DIR)
os.chdir(DATA_DIR + '/domains/')
for file in os.listdir('.'):
if os.path.isfile(file):
file_mod_time = datetime.datetime.fromtimestamp(os.path.getmtime(file))
Expand Down

0 comments on commit 5d6911a

Please sign in to comment.