A small script to process SMTP delivery reports
This small script connects to an IMAP4 mailbox, and looks for the unread messages containing a DSN.
Delivery Status Notifications are MIME parts generated by SMTP server to indicate message delivery events.
See RFC 3664 for more details https://datatracker.ietf.org/doc/html/rfc3464
The program reads IMAP settings from a configuration file conforming to INI syntax.
The output is a CSV file.
The goal of the script is to synthetize into a simple single report the many returns received when mailing multiple adresses to process undelivered or delayed messages.
Current version only manages DSN for a single recipient. RFC allows for multiple recipients to be addressed by a single DSN. This case is rare and not managed by current version of this script.
ump.py [-h] [-c CONFIG] [-o OUTPUT]
Optional arguments:
-h
,--help
show the help message and exit-c CONFIG
,--config CONFIG
configuration file-o OUTPUT
,--output OUTPUT
destination file
[imap]
server=YourServerFQDN
port=YourServerPort
login=YourLoginHere
password=YourPasswordHere
folder=INBOX
- Checkout the project
- install dependencies (in a
VirtualEnv
preferably) - customize the configuration file
- run
The following Python3 modules are required:
argparse
configparser
csv
datetime
email
imaplib2
logging
rich
Most of them should be pre-installed with your Python3 distribution.