Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

dd701116
Copy link
Contributor

  • Manage error when mail don't have attachement
  • Add extract when attachement is an xml file
  • Fix reverse dkim and spf column

@dd701116 dd701116 changed the title New features : extract xml files New feature : extract xml files May 26, 2020
Comment on lines +218 to +223
if extension == "gz":
mime_tmp = mime
mime = MIME_GZIP[0]
elif extension == "zip":
mime_tmp = mime
mime = MIME_ZIP[0]
Copy link
Contributor Author

@dd701116 dd701116 May 27, 2020

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.

Comment on lines +19 to +25
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))
Copy link
Contributor Author

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.

Comment on lines 76 to +77
<td class="{{ line[7] }}">{{ line[7] }}</td>
<td class="{{ line[6] }}">{{ line[6] }}</td>
Copy link
Contributor Author

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

Copy link
Contributor Author

@dd701116 dd701116 left a 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 !

Copy link
Owner

@cjeanneret cjeanneret left a 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
Copy link
Owner

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"
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants