Moved docs to README.md
This commit is contained in:
37
getmail.py
37
getmail.py
@@ -3,42 +3,7 @@
|
||||
"""
|
||||
Developed by Greig McGill of Sense7.
|
||||
|
||||
This script is designed to poll an IMAP mailbox when run.
|
||||
It will find any emails with attachments, marking them as read, and saving
|
||||
the attachment to the 'attachments' directory for later processing.
|
||||
It will respect the attachment filetype and extension.
|
||||
Attachments are output named with the current date-time, and a semi-random
|
||||
uid based on the file hash in order to prevent namespace collisions.
|
||||
|
||||
No file locking is used, however files are written to a temporary directory
|
||||
first, flushed, and renamed upon completion, as renaming is an atomic operation
|
||||
at an OS level.
|
||||
|
||||
Attachments will not be created if they have an identical hash to a
|
||||
previously downloaded attachment. This is designed to prevent scenarios where
|
||||
the same file has been accidentally sent multiple times. Note that this
|
||||
identification is done based on file content, and the name of the file is
|
||||
irrelevant.
|
||||
|
||||
Once an attachment is saved, we look up the mapping of fields in the attachment
|
||||
for input, using a custom mapping based on the domain of the email address of
|
||||
the sender. Different companies may use differing CSV formats, but we work on
|
||||
the assumption tha the XML for input into Logistic will need to be the same and
|
||||
based on a well defined DTD.
|
||||
|
||||
After mapping and conversion to XML, the file is validated against the DTD and
|
||||
written to the xml directory for injection into logistic.
|
||||
|
||||
Logging is fairly primitive and done to a log file in the same directory as
|
||||
the script. This could be upgraded to syslog-style logging if required.
|
||||
|
||||
This is set up for simple IMAP SSL authentication using TLS with implied
|
||||
STARTTLS. If manual STARTTLS is required, the MailBox method will need to be
|
||||
altered to MailBoxTls. If Outlook or Gmail or similar are used, it will be
|
||||
necessary to implement OAUTH2.
|
||||
|
||||
Authentication and other user configuration is configured in a .env file as
|
||||
described below in the code.
|
||||
See README.md for full documentation and version history.
|
||||
"""
|
||||
|
||||
# Standard libraries
|
||||
|
||||
Reference in New Issue
Block a user