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

Not able to parse an email: no media type #24

Closed
kalbasit opened this issue Oct 5, 2015 · 8 comments
Closed

Not able to parse an email: no media type #24

kalbasit opened this issue Oct 5, 2015 · 8 comments
Assignees
Labels
Milestone

Comments

@kalbasit
Copy link

kalbasit commented Oct 5, 2015

Email content:

From: "Keith Packard" <keithp@keithp.com>
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 18:03:17 -0800
Subject: [notmuch] Introducing myself
In-Reply-To: <20091118002059.067214ed@hikari>
References: <20091118002059.067214ed@hikari>
Message-ID: <yun1vjwegii.fsf@aiko.keithp.com>

On Wed, 18 Nov 2009 00:20:59 +0100, Adrian Perez de Castro <aperez at igalia.com> wrote:

> Some time ago I thought
> about doing something like Not Much and in fact I played a bit with the
> Python+Xapian and the Python+Whoosh combinations, because I find relaxing
> to code things in Python when I am not working and also it is installed
> by default on most distribution. I got to have some mailboxes indexed and
> basic searching working a couple of months ago.

Sup certainly started a lot of people thinking...

> Also, I would like to share one idea I had in mind, that you might find
> interesting: One thing I have found very annoying is having to re-tag my
> mail when the indexes get b0rked (it happened a couple of times to me while
> using Sup), so I was planning to mails as read/unread and adding the tags
> not just to the index, but to the mail text itself, e.g. by adding a
> "X-Tags" header field or by reusing the "Keywords" one.

Easier than that, notmuch (and sup too), provide a 'dump' command which
just lists all of the message IDs and their associated tags. Makes
saving tags easy and doesn't involve rewriting messages. I do this once
a day just before my computer is backed up to an external drive.

If the index is destroyed, you can reindex the messages and then reapply
all of the tags with 'notmuch restore'.

--
keith.packard at intel.com

Getting the error mime: no media type when I try to parse the email above. Found that developing Gmuch email_bug branch.

@jordan-wright
Copy link
Owner

Hey there!

Unfortunately, this is an issue I'm working on. This is likely because you having a blank line at the beginning?

If that's the case, try removing the blank line and giving it a shot again. I plan to strip that automatically soon.

On Oct 5, 2015, at 2:07 AM, Wael M. Nasreddine notifications@github.com wrote:

Email content:

From: "Keith Packard" keithp@keithp.com
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 18:03:17 -0800
Subject: [notmuch] Introducing myself
In-Reply-To: 20091118002059.067214ed@hikari
References: 20091118002059.067214ed@hikari
Message-ID: yun1vjwegii.fsf@aiko.keithp.com

On Wed, 18 Nov 2009 00:20:59 +0100, Adrian Perez de Castro wrote:

Some time ago I thought
about doing something like Not Much and in fact I played a bit with the
Python+Xapian and the Python+Whoosh combinations, because I find relaxing
to code things in Python when I am not working and also it is installed
by default on most distribution. I got to have some mailboxes indexed and
basic searching working a couple of months ago.

Sup certainly started a lot of people thinking...

Also, I would like to share one idea I had in mind, that you might find
interesting: One thing I have found very annoying is having to re-tag my
mail when the indexes get b0rked (it happened a couple of times to me while
using Sup), so I was planning to mails as read/unread and adding the tags
not just to the index, but to the mail text itself, e.g. by adding a
"X-Tags" header field or by reusing the "Keywords" one.

Easier than that, notmuch (and sup too), provide a 'dump' command which
just lists all of the message IDs and their associated tags. Makes
saving tags easy and doesn't involve rewriting messages. I do this once
a day just before my computer is backed up to an external drive.

If the index is destroyed, you can reindex the messages and then reapply
all of the tags with 'notmuch restore'.

keith.packard at intel.com
Getting the error mime: no media type when I try to parse the email above. Found that developing Gmuch email_bug branch.


Reply to this email directly or view it on GitHub.

kalbasit added a commit to kalbasit/email that referenced this issue Oct 5, 2015
@kalbasit
Copy link
Author

kalbasit commented Oct 5, 2015

Hey Jordan,

I don't have a new line at the beginning, this seems to be from a different issue.

screen shot 2015-10-05 at 09 19 52

I added a failure test in kalbasit/email@e614fb5

@jordan-wright
Copy link
Owner

Thanks for that failure case! That helps quite a bit. I believe that there are two possible causes:

  1. No "MIME-Version: 1.0" header - I don't know if this is mandatory, but I'll check the RFC.
  2. No "Content-Type" header. This should default to "text/plain; charset=us-ascii" but I'll need to make sure this is happening.

Let me look into this and I'll get back to you asap.

@jordan-wright jordan-wright self-assigned this Oct 5, 2015
@kalbasit
Copy link
Author

kalbasit commented Oct 6, 2015

perfect, thanks Jordan.

@jordan-wright
Copy link
Owner

Ok, I've found a few issues that need to get resolved.

The root cause is that there is no Content-Type header. This should default to "text/plain; charset=us-ascii", but it looks like the logic to handle that is not in the stdlib (from what I can tell).

So, when parsing the media type disposition, we get the error since there is no "Content-Type" in the map of headers.

That's number one. The second issue is that my parsing logic currently assumes that the email will be a multipart email. So, even if you add the Content-Type, the body won't be parsed.

I need to add the logic to handle non-multipart emails, so I'll probably make another issue for it. All in all, I'll probably setup two new issues for these, and keep this one open in the meantime until both are resolved.

I'll knock this out as soon as I can, but it might be a week or so due to time constraints.

@kalbasit
Copy link
Author

kalbasit commented Oct 6, 2015

That works for me, thanks Jordan.

@jordan-wright jordan-wright added this to the v2.2 milestone Oct 13, 2015
@jordan-wright
Copy link
Owner

Ok, @kalbasit, I think I fixed the issue with 48c3347. Would you mind confirming?

If we're good to go, I'll close out this issue.

@kalbasit
Copy link
Author

This is fixed, I have another issue though, so I'll open a separate issue for it

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

No branches or pull requests

2 participants