[Dovecot] list all emails from command line?

Joseph Tam jtam.home at gmail.com
Tue Jun 3 03:02:14 UTC 2014


> Therefore, I wanted to do some kind of "IMAP list" of the account, with
> a command line tool:
>
> - specify username, pass and server,
> - the tool would return a list of all email in their folders (message
>  ID, From, To, Date, Subject).
>
> I would run it i.e. daily and this would let me verify when the mail was
> really visible in the account.
>
> Is anyone aware of a tool I could use to achieve that?

Not offhand, but if you want a remote tool, it ought to be simple to
cobble together some feeder script and netcat (or openssl s_client).
It will also be simpler if you configure the master password feature so
you don't have access to all user passwords.

So something like this for dumping the INBOX contents

 	#!/bin/sh

 	master-user=masteru
 	master-password=masterp

 	while read user server; do
 	netcat --ssl $server 993 <<_EOF_ >${user}.report
 	1 LOGIN ${user}*${master-user} ${master-password)
 	2 SELECT INBOX
 	3 ...
 	4 LOGOUT
 	_EOF_
 	done

I don't know enough IMAP to fill in "3 ..." to dump all headers, but I'm
sure it's not hard to find out.

It's even simpler if you don't need to do it remotely: just use

 	doveadm fetch -A hdr MAILBOX '*'

Joseph Tam <jtam.home at gmail.com>


More information about the dovecot mailing list