3

How do you get a list of users for a dovecot email server that connect via IMAP (as opposed to POP)?

Our server is setup to authenticate via LDAP/PAM. Is there an easy way to get a list of the users who are accessing their mail via IMAP, rather than POP? I am about to migrate our server to Google Apps and want to migrate all of the mail for my IMAP users only (couple hundred out of several hundred total users). POP mail will be migrated separately from the client end obviously.

I would much rather migrate only the IMAP users rather than the whole domain which would include migrating a bunch of POP mail left in the server that has already been read/sorted/deleted in the client's email program. Migrating all of that extra useless leftover POP mail could waste weeks of migration time.

I suppose parsing some logs to see who has connected on an IMAP port (995 or 993) would give me a list would work if someone could help me do that. I know I have the raw dovecot logs, but am hoping for a cleaner solution.

1 Answer 1

2

To get a list of logins:

cat /var/log/mail.log | grep imap-login 

Now we need to cut it down to something a little more useable -- filter out the username, and eliminate duplicates:

cat /var/log/mail.log | grep imap-login:\ Login | sed -e 's/.*Login: user=<\(.*\)>, method=.*/\1/g' | sort | uniq

This gets the imap logins that complete (supply a name), uses sed with a regex to cut out the name, sorts it and then takes the unique names.

1
  • Thank you! So much cleaner than the PHP script I wrote to do it. I REALLY need to learn how to use regex without just googling ten million different things until something works. Sep 30, 2012 at 3:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .