Re: [Dovecot] list all emails from command line?
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@gmail.com>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Mon, 2 Jun 2014, Joseph Tam wrote:
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.
3 fetch 1:* RFC822.HEADER
It's even simpler if you don't need to do it remotely: just use
doveadm fetch -A hdr MAILBOX '*'
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUBU41nFHz1H7kL/d9rAQIEkggAoqpjh3Yn/0lJbGSf9D4zI/TO8utmUGtK ZqmZ/j9KOm7+GvaS3z4WqlIkwfYFqIgTuiLBn9bHU6Dzynr+DDD8ydqGxiaQa3WY XgDQv6xU/bti4NXMZtpRxKg8r/SXW3Y/N36Y9sH3yYf7LTopQh1rW9cEdiyWY8c5 AjPmSdzxXnlmrwCCtJvjEPjvSZbIN2ilAXPMaDCbDNKZM7/VNvB+Yi8P7c6zdq6s Hdjn9h4FEqoB9zgiEGC1z4YSzVjaTGS7a+1+gS7WUJ6BX1al04eT4FlTu4WetTU8 mJmZAO/c8OA/+1FO1HW2u3FRhd1gIH/CRigfuGgfT7hwN3xcej1FPA== =gzhc -----END PGP SIGNATURE-----
participants (2)
-
Joseph Tam
-
Steffen Kaiser