Search program that can find an E-Mail with an exact Date: match
John Hawkinson
jhawk at alum.mit.edu
Tue Nov 30 15:24:10 UTC 2021
I find this discussion a bit…surprising? It seems like "mboxgrep" (https://datatipp.se/mboxgrep/) does this just fine. E.g.
mboxgrep -rH -m maildir 'Date: Sun, 17 Mar 2019 21:24:26 -0700' dir
recursively searches the headers of all mailboxes within 'dir' for the pattern specified. I don't know that "-m maildir" is necessary, but it works.
And if you don't have mboxgrep or don't feel like installing it (e.g. for a one-off), just plain old grep will get you 90% of the way there, assuming you can tolerate a few false positives if there are email messages that happen to have that same date string in their bodies (e.g. quoting messages):
fgrep -r 'Date: Sun, 17 Mar 2019 21:24:26 -0700' dir
And of course you could add a ^ to the front and make it a regexp (and add -G in the case of mboxgrep, or switch to grep from fgrep).
Oh, you ask:
> I can grep for the E-Mail but then I'm left with the issue of
> extracting the body/text which is what I actually want. Can I
> 'pipe' the mailbox (found by grep) into mutt and then get the
> output on stdout, that's what I'd need.
Well, you can just use grep to determine which file contains what you want, and direct mutt to that particular mailbox file.
It does not, to me, seem like this is either "odd" or a "corner case." This is searching for a particular header in a set of messages, that should not be a rare requirement, although of course many people never do it. It is also, however, out of scope for mutt — mutt isn't a tool for searching multiple mailboxes. Perhaps there's a better mailing list for this sort of question?
--
jhawk at alum.mit.edu
John Hawkinson
> Chris Green <cl at isbd.net> writes:
>
> > I'm looking for a way to find (and display) an E-Mail when I know
> > the exact value of the Date: header.
> > The 'usual' search programs such as Mairix can't do this as they
> > all expect a date range and also expect it to be at least a day
> > long.
> > I've also tried grepmail but that seems not to be able to search
> > maildir E-Mails.
> >
> > Is there anything out there that can do this?
> > I can grep for the E-Mail but then I'm left with the issue of
> > extracting the body/text which is what I actually want. Can I
> > 'pipe' the mailbox (found by grep) into mutt and then get the
> > output on stdout, that's what I'd need.
More information about the Mutt-users
mailing list