-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
666 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,11 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
/.vs/o365getmail/v16 | ||
/o365getmail/mails/[email protected] | ||
/o365getmail/tests | ||
/o365getmail/tokens | ||
/TestResults | ||
/o365getmail.sln | ||
/o365getmail/o365getmail.pyproj | ||
/o365getmail/o365getmail.pyproj.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
# o365getmail | ||
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 | ||
## Getting Started | ||
**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** | ||
|
||
## Available flags | ||
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.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Manuel Lauk | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# o365getmail | ||
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 | ||
## Getting Started | ||
**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** | ||
|
||
## Available flags | ||
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.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Configuration settings for running the o365getmail script. | ||
In productive system, ensure file can't be accessed by unpriviledged. | ||
""" | ||
|
||
import os | ||
|
||
CWD = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
CLIENT_ID = 'e0b4909c-1802-4431-874f-824b5590827f' | ||
CLIENT_SECRET = 'zHix7WsUU7/g?.]9drRLfFj36Pt:E897' | ||
|
||
|
||
MAIL_PATH = os.path.join(CWD, 'mails') | ||
TOKEN_PATH = os.path.join(CWD, 'tokens') | ||
LOG_PATH = os.path.join(CWD, 'o365_email_getter.log') | ||
|
||
|
||
|
||
# AUTHORITY_URL ending determines type of account that can be authenticated: | ||
# /organizations = organizational accounts only | ||
# /consumers = MSAs only (Microsoft Accounts - Live.com, Hotmail.com, etc.) | ||
# /common = allow both types of accounts | ||
AUTHORITY_URL = 'https://login.microsoftonline.com/common' | ||
|
||
AUTH_ENDPOINT = '/oauth2/v2.0/authorize' | ||
TOKEN_ENDPOINT = '/oauth2/v2.0/token' | ||
|
||
RESOURCE = 'https://graph.microsoft.com/' | ||
API_VERSION = 'beta' | ||
#['basic', 'message_all'] | ||
SCOPES = ['User.Read', 'offline_access', 'Mail.ReadWrite', 'Mail.Send'] # Add other scopes/permissions as needed. | ||
|
||
|
||
# Getter definitions for message pull | ||
USERS = [] | ||
USERS.append({"user_id":"[email protected]", "queue":"Microsurgery", "action":"correspond"}) | ||
#USERS.append({"user_id":"[email protected]", "queue":"Ophthalmic", "action":"correspond"}) | ||
|
||
|
||
# MDA settings | ||
RT_URL = 'https://dev-med-rt.zeiss.com/' | ||
CA_FILE = '/usr/local/share/ca-certificates/dev-med-rt.zeiss.com/dev_med_rt.zeiss.com.cer' | ||
# "MDA": "/opt/rt4/bin/rt-mailgate --queue 'Microsurgery' --action correspond --url https://dev-med-rt.zeiss.com/ --ca-file /usr/local/share/ca-certificates/dev-med-rt.zeiss.com/dev_med_rt.zeiss.com.cer" | ||
|
||
|
||
|
||
# This code can be removed after configuring CLIENT_ID and CLIENT_SECRET above. | ||
if 'ENTER_YOUR' in CLIENT_ID or 'ENTER_YOUR' in CLIENT_SECRET or 'ENTER_YOUR' in MAIL_PATH or 'ENTER_YOUR' in TOKEN_PATH or 'ENTER_YOUR' in LOG_PATH: | ||
print('ERROR: config.py does not contain valid CLIENT_ID and CLIENT_SECRET') | ||
import sys | ||
sys.exit(1) |
Oops, something went wrong.