-
Notifications
You must be signed in to change notification settings - Fork 385
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
[Bug] Retrieve email headers #895
Comments
Ok, have you already written something? The problem is exchange connection or processing the email? |
Both. I'm not familiar with exchangelib in python but I found something maybe useful to retrieve the header of the last mail in my inbox. import exchangelib as E user = 'wgates@microsoft.com' class RawHeaders(E.ExtendedProperty): print("Logging in…") print(account.inbox.all()[0].rawheaders) |
this is a function I wrote to connect to owa [similar to yours 😄 but probably your is missing some server info]
Then you can use To get email info I suggest using specialized lib like eml_parser
|
Thank you. but how should I retrieve the header of a specific mail? |
What do you mean with specific? you can search by message-id for example if you have it
|
Sorry if I was not clear. I mean instead of (account.inbox.all()[0])['header'] that is the first inbox, Can I search for a specific message in my inbox? |
you can search for whatever, see https://ecederstrand.github.io/exchangelib/#searching for example. |
Thank you. I just want to ask what is the parameter of the delegate server that I should put in the json file? email.py #!/usr/bin/env python3 encoding: utf-8from cortexutils.analyzer import Analyzer class Email_Header_Mxtoolbox(Analyzer):
if name == 'main': email.json { |
delegate_account? For example if you have a functional email you can login with your account and read mail as the functional one (eg. security_mbx@evilcorp.com 😄 ), if not you can put the same value you used as username. |
Okey deal. I will test it to verify the header so I can move to next step that is mxtoolbox. |
Hello @dadokkio. I tested my script. I was able to connect to the exchange server and retrieve my email header for a specific subject. But it returns a list thats why the analyser crash. I also tried the parser that you gave me but I could not be able to receive me header in a dictionary form. Can you help me doing this? I should receive a dictionary so when I put "self.report(dictionary) it will return a json and the analyser will be successfull" Python script
json file
cortex result |
you can also create the dict when you invoke self.report and keep item.headers as a list. In any case I'm not really sure how you'll use this analyzer and if I have understood properly this is not the right approach. |
I solved the issue Thank you for your help. I will keep you posted when i configure another analyser. |
Great. I'll close the issue. If you need any other help just ask! |
Hello, I should build an analyser that retrieve the header of a specific mail on exchange and than I want to analyse the header using mxtoolbox. Can someone help me to do it? I'm stuck.
Thank you.
The text was updated successfully, but these errors were encountered: