Retrieve Last Login of email account via IMAP / POP3 / WEBMAIL


I'm looking to programmatically retrieve the last login date of a particular email account via IMAP, POP3, or the webmail client that we offer. I'm failry sure I can figure out the webmail client thing myself, but where I'm stuck is IMAP and POP3.

We use courier for IMAP and postfix for POP3 on a linux box. I need any kind of a command or something to retrieve either all logins and the date the logged in, or per account and I'll look through them myself.

I've been looking on the internet and I've seen nothing that is even remotely close. I'm not a very good googler =P

Any help would be mucho appreciated. Thank you!

(ill be responding to this topic very quickly, so dont go anywhere!)

P.S. We use squirrelmail as our webmail client.
Who is Participating?
Cyclops3590Connect With a Mentor Commented:
postfix isn't a pop3 server, its smtp only

I use courier as well, but it depends where the syslog conf file is configured to deliver those log messages
cat /etc/syslog.conf | grep mail
will tell you where to look
then what I do is this
cat <<log file>> | egrep "(imapd|pop3d)" | grep <<username>> | tail -1
not elegant, but it gets the job done for me.  then if you wanted to you could make that into a bash script where it accepts one parameter, the username, for easier usage later.
digitalpacmanAuthor Commented:
Thanks I will try that tommorow... well my sysadmin is what told me these things are. I'm a programmer.. so I just write their perl scripts and assist in hardware/software changes.. but only theoritical I don't deal in that world.

But thanks I'll try that hopefully it works my boss is ridin me hard for this =p

(we are reaching max diskspace so we need to write a cleanup script that disables unused accounts)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.