-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature : extract xml files #3
base: master
Are you sure you want to change the base?
Conversation
dd701116
commented
May 26, 2020
- Manage error when mail don't have attachement
- Add extract when attachement is an xml file
- Fix reverse dkim and spf column
if extension == "gz": | ||
mime_tmp = mime | ||
mime = MIME_GZIP[0] | ||
elif extension == "zip": | ||
mime_tmp = mime | ||
mime = MIME_ZIP[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add this because when I receive a report sent by Yahoo, the mimetype of the 'gz' file is 'application/xml' but the file is a real archive.
I forced the mimetype and before the change I save the value in a tmp variable in case we have to debug.
if f_name: | ||
dest = os.path.join('./reports', f_name) | ||
if os.path.exists(dest): | ||
return | ||
with open(dest, 'wb') as f: | ||
f.write(attachment.get_payload(decode=True)) | ||
os.utime(dest, (mtime, mtime)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the 'f_name' variable is undifined, I assume that the mail does not have an attachment.
<td class="{{ line[7] }}">{{ line[7] }}</td> | ||
<td class="{{ line[6] }}">{{ line[6] }}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inverse SPF and DKIM columns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave somme comment in order to explain why I make the modification.
Thanks for your work, its very helpfull.
See you !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello there !
I know it's been a reeeally long time - I didn't get github notification for some reason, and since I don't use this script for a bit more than a year, I kind of forgot about this....
If you could address the couple of comments, that would allow to get a clean merge. Sorry again for the long delay.
|
||
|
||
# Create the plain-text and HTML version of your message | ||
text = file_get_contents(filename) # il affichera le code html brute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
French ;)
@@ -6,3 +6,9 @@ offlineimap -l offlineimap.log -c offlineimaprc | |||
echo "Extracting attachments" | |||
test -r my_ips && source my_ips | |||
./extract.py | |||
|
|||
echo "Sending report" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may be optional imho
server.ehlo() # Can be omitted | ||
#server.starttls(context=context) # Secure the connection | ||
server.sendmail(sender_email, receiver_email, text) | ||
# TODO: Send email here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm afaik the mail is actually sent the line before?
try: | ||
server = smtplib.SMTP(smtp_server,port) | ||
server.ehlo() # Can be omitted | ||
#server.starttls(context=context) # Secure the connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc there's a way to make the smtplib chose the right connection type.