[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Ideas to obtain text file list of emails in an IMAP folder?



On Sat 04 Jun 2016 at 00:06:34 (-0000), Dan Purgert wrote:
> Ron Leach wrote:
> > On 03/06/2016 17:31, Dan Purgert wrote:
> >> Ron Leach wrote:
> >>> Have any debian-user readers ever tried to create a list of all the
> >>> email messages stored in an IMAP folder?
> >
> >> Do the same here (Dovecot + Postfix), not 100% certain if this'll match
> >> your setup, but it should be pretty close.

> >>> [...] The person
> >>> doing this would be the person whose mailbox it is, and would have the
> >>> IMAP passwords etc.

> >> [snip]
> >>
> >> #!/bin/bash
> >> [...]

> >> if [[ $EUID -ne 0 ]]; then
> >>   printf "\nSorry, this script must be run as root.\n"
> >>   exit 0
> >> fi

> >> [snip most of the the script body]
> >
> > Well.  That worked very well.  Clever, too; I was thinking I'd need to 
> > use the imap protocol to extract the headers from Dovecot, in the same 
> > way that an email client does.
> 
> Nah, IMAP is just a protocol for accessing the messages (similar to how
> "HTTP" is the protocol for viewing "documents" over the internet).
> Since you have direct access to the box, we can skip all that mess. 

How does your script deal with the users' IMAP passwords, or prevent
the sudo-priveleged users from reading each others' emails?

I was interested in seeing how this problem would be tackled "through"
IMAP. I should be able coerce mutt into writing a fresh cache of the
headers in an INBOX thus:

Run mutt with a special configuration file: mutt -F conffile
and open the appropriate inbox:                  -f imaps://.../INBOX
readonly if required:                            -R

conffile contains:
set header_cache=some-empty-directory
set imap_headers="X-ORIGINAL-TO RETURN-PATH"
set spoolfile="imaps://...passwords.../INBOX

The cache will appear in a folder under some-empty-directory and
any non-default headers can be included by setting imap_headers.

It might be sufficient to specify -f '!' (as spoolfile is set).

file says the resulting cache is a "Tokyo Cabinet (1.0:911)" and
I have no idea how to list its contents. It would be neat to have
a customised listing (with width unrestricted by the terminal) of
my INBOX on the IMAP server to which I *don't* have privileged access.

Cheers,
David.


Reply to: