Retrieve Emails from Office365 via MSGraph Interface
This Python script may be used to retriev emails from Office 365
according to the new OAuth protocol. It's not the perfect solution right now.
This script tries to fix malformed Emails by boxing them into a forward mail.
Feel free to improve the script and in case you find some better solution, please let me know.
Requirements:
Python 3
see imports at script header
First run:
execute the script with python o365getmail --auth
to get initial tokens.
You will get a URL for past an copy to an Browser for Identification. After successful identification copy the returnd URL and past it back.
After successful token creation execute:
execute the script silent: ./o365getmail
or
execute the script: ./o365getmail --verbose
After success use it with cron
Short | Long | Explanation |
---|---|---|
--version | 'Print script version.' | |
-a | --auth | 'Get initial or refresh token if authentification expired.' |
-k | --keep | 'Keep messages after pushing to MDA.' |
-v | --verbose | 'Output logger infromation to Screen.' |
-m | --message | 'Email message as ''*.eml'' to push to RT.' |
-l | --limit | 'Limit email pull to number of message to be pulled at once.' |