Initial rough
This commit is contained in:
27
smart.py
Normal file
27
smart.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
import base64
|
||||||
|
import sys
|
||||||
|
import fileinput
|
||||||
|
import os
|
||||||
|
import email
|
||||||
|
|
||||||
|
archiveDir = '/var/www/html/reports/'
|
||||||
|
|
||||||
|
rawEmail = sys.stdin.read().decode('utf-8')
|
||||||
|
|
||||||
|
emailObject = email.message_from_string(rawEmail)
|
||||||
|
|
||||||
|
for part in emailObject.walk():
|
||||||
|
if part.get_content_maintype() =='multipart':
|
||||||
|
continue
|
||||||
|
if part.get('Content-Disposition') is None:
|
||||||
|
continue
|
||||||
|
fileName = part.get_filename()
|
||||||
|
|
||||||
|
if bool(fileName):
|
||||||
|
filePath = os.path.join(archiveDir, fileName)
|
||||||
|
|
||||||
|
if not os.path.isfile(filePath):
|
||||||
|
fp = open(filePath, 'wb')
|
||||||
|
fp.write(part.get_payload(decode=True))
|
||||||
|
fp.close()
|
||||||
Reference in New Issue
Block a user