Giter Club home page Giter Club logo

Comments (11)

fedelemantuano avatar fedelemantuano commented on May 31, 2024

Hi,
which version of mailparser are you using?

from mail-parser.

ajurna avatar ajurna commented on May 31, 2024

mail-parser==1.2.1
i can pm you the data. but i don't really want to post it publicly?

from mail-parser.

fedelemantuano avatar fedelemantuano commented on May 31, 2024

You could send me a mail on

mantuano.fedele at gmail.com

Is response_part[1] a byte type? Did you try with mailparser.parse_from_string?

from mail-parser.

ajurna avatar ajurna commented on May 31, 2024

i use pycharm and looked through it with the debugger.
code is below. the data inspected was of bytes type
this is in python3.6 and i forwarded you the unsanitised data to your email

def check_mail_by_id(self, message_id: AnyStr) -> mailparser.MailParser:
    _, header_data_raw = self.imap.fetch(message_id, '(BODY.PEEK[HEADER])')
    for response_part in header_data_raw:
        if isinstance(response_part, tuple):
            headers = mailparser.parse_from_bytes(response_part[1])
            return headers

from mail-parser.

fedelemantuano avatar fedelemantuano commented on May 31, 2024

In your header there isn't the to:

File "C:\project\venv\lib\site-packages\mailparser\mailparser.py", line 217, in make_mail
"to": self.to
,
File "C:\project\venv\lib\site-packages\mailparser\mailparser.py", line 383, in to_
self.message.get('to', self.message.get('delivered-to')))

So the parsing fails because the email should have to.

Are you sure that you take all email with self.imap.fetch.
mailparser works with all raw mail.

from mail-parser.

ajurna avatar ajurna commented on May 31, 2024

well i'm parsing the headers first. You can see that i'm using the BODY,PEEK[HEADER] in the fetch
this mail when i checked in outlook didn't have anyone in the to section either.
the only thing missing should be the body of the mail.

from mail-parser.

fedelemantuano avatar fedelemantuano commented on May 31, 2024

The best way is:

  • Get all mail, and put it in a variable
  • Check with print the header (only for debug)
  • I could fix this problem, but the mail should have a to in the headers

The code part is this.

from mail-parser.

ajurna avatar ajurna commented on May 31, 2024

i saw that. my issue is that this mail doesn't have a deliviered-to header. which makes the parser fail.
the mail is being read by imap from office365.
i don't want to pull the full mails as in my use case i'm accessing my own inbox and it's simpler to not have to mark everything unread again.

from mail-parser.

fedelemantuano avatar fedelemantuano commented on May 31, 2024

Ok, you can take only headers, and mailparser should work fine because there are mails without body or attachments.
In your mail there aren't to and deliviered-to header, because deliviered-to header is the fallback of to.
You can try to catch TypeError and print headers. Then post here obfuscated hearders, so I can check.

from mail-parser.

ajurna avatar ajurna commented on May 31, 2024

that's why i emailed you the headers.

from mail-parser.

fedelemantuano avatar fedelemantuano commented on May 31, 2024

Fixed with commit 0219562c84de32d63deb10417278380063337024

from mail-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.