This is not strictly Dovecot question, but a more general IMAP one. I'm running a Dovecot server and have a user who is claiming that some email sent to him, say, on 30 May, showed up in his mailbox on 02 Jun. I've checked Postfix logs, and the message was correctly received on 30 May and passed to Dovecot. A similar issue happens every few days. This leaves me with two possibilities: 1) Dovecot is somehow not presenting the new mail to the user in a "timely manner" 2) user's email program is broken 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? -- Tomasz Chmielewski http://www.sslrack.com
Hi I would recommend writing some small check scripts using perl IMAP module. You can even develop your own monitoring plugins this way. A different option would be to execute mutt in batch mode on the command line. Regards Daniel
This seems like a pretty complicated (and time / labor intensive) way to solve the problem. That said, if this is the way you want to approach the problem, Python's imaplib is pretty good at doing this kind of thing. This may not format it exactly the way you want, but it should give you a starting point. Lots of examples online. I haven't played with it much, but I think there are some things that will let you do some extended logging of IMAP commands from within Dovecot - that might be a better way to figure out why the user's client doesn't seem to be noticing the message in a timely manner. **** #!/usr/bin/env python import email import imaplib IMAPHOST='somehost.example.com' USER='username' PASSWORD='mysecretgarden' i = imaplib.IMAP4_SSL(IMAPHOST) i.login(USER, PASSWORD) for folder in i.list()[1]: folder = folder.split(' "/" ')[1] print "**** %s ****" % folder i.select(folder) typ, [msg_ids] = i.search(None, 'ALL') for num in msg_ids.split(): typ, msg_data = i.fetch(num, '(BODY.PEEK[HEADER])') for response_part in msg_data: if isinstance(response_part, tuple): email_message = email.message_from_string(response_part[1]) to = email.utils.parseaddr(email_message['to']) subject = email_message['Subject'] msgid = email_message['Message-ID'] sender = email.utils.parseaddr(email_message['From']) print "%-30s => %-30s %-30s (%s)" % (sender[1], to[1] + ':', subject[0:30], msgid)