Is there anyway I can get Dovecot to update mtime on dovecot.index everytime a user successfully checks there email? Or perhaps there is a better way to do what I want here. I am working on a script that I want to check when the last time a user checked there email account. If a user has not checked it in say 6 months I want to automatically suspend the account through the MTA. If they start checking it again I also want to automatically reinstate it. What I thought was a good way was to look at the mtime on dovecot.index but a user can be checking there email daily but if they do not receive a new message in say 6 months the mtime will date back to 6 months still. Ran into this with an email address used by a fax machine. So is there a better way with dovecot to determine this? I am using dovecot-1.0.rc29 right now. Matt
On Sat, 10 Nov 2007, Matt wrote:> Is there anyway I can get Dovecot to update mtime on dovecot.index > everytime a user successfully checks there email? Or perhaps there is > a better way to do what I want here. > > I am working on a script that I want to check when the last time a > user checked there email account. If a user has not checked it in say > 6 months I want to automatically suspend the account through the MTA. > If they start checking it again I also want to automatically reinstate > it. What I thought was a good way was to look at the mtime on > dovecot.index but a user can be checking there email daily but if they > do not receive a new message in say 6 months the mtime will date back > to 6 months still. Ran into this with an email address used by a fax > machine. > > So is there a better way with dovecot to determine this? I am using > dovecot-1.0.rc29 right now.[From an email I wrote in October] You can do this (and many other things) through Post-Login Scripting: http://wiki.dovecot.org/PostLoginScripting See in particular ?Last-login tracking?: http://wiki.dovecot.org/PostLoginScripting#line-20 [...and for your situation:] I think I'd avoid actually disabling the account through the MTA, especially if it's for security considerations and your accounts have shell access. But it wouldn't be that hard: In dovecot.conf, set your IMAP login script as follows: protocol imap { # ... mail_executable = /full/path/to/loginscript.sh Then, use the attached loginscript.sh. (and chmod +x it) Tested with 1.0.5 under Gentoo. The 'stat' and 'date' commands might need alteration depending on your particular flavor of O/S. (I also realized after writing it that you probably meant to disable mail delivery, not IMAP access. But, it was a fun exercise.) In that case, all you need in loginscript.sh is: #!/bin/sh touch $HOME/.dovecot-lastlogin exec /usr/libexec/dovecot/imap Then run a cron job to disable delivery through your MTA of choice. Best, Ben -------------- next part -------------- A non-text attachment was scrubbed... Name: dovecot-login.sh Type: application/x-sh Size: 608 bytes Desc: URL: <http://dovecot.org/pipermail/dovecot/attachments/20071110/0124f4b0/attachment-0002.sh>
> I think I'd avoid actually disabling the account through the MTA, > especially if it's for security considerations and your accounts have > shell access. But it wouldn't be that hard:My actual goal is to reduce load on the server. These are simply email users and have no shell or any other access. If there not using the account I do not want Exim wasting resources virus scanning, spam scanning(spamd) and storing messages for them. I want to add all email users that have not checked email through pop3 or imap in ~6 months to /etc/virtual/suspended_email. Exim will reject messages to these accounts with error message: "Account suspended due to inactivity". I do not want to suspend pop3 or imap access in fact if they start using the account again I want to automatically re-enable. Likely will run a script in cron.daily to check all this. I think that better explains what I am after. Thanks. Matt
On Sat, 2007-11-10 at 18:12 -0600, Matt wrote:> Is there anyway I can get Dovecot to update mtime on dovecot.index > everytime a user successfully checks there email?Postlogin scripting would work like Benjamin said. Another possibility would be to check atime if you haven't disabled atime updates. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20071111/3918c87d/attachment-0002.bin>
> > Is there anyway I can get Dovecot to update mtime on dovecot.index > > everytime a user successfully checks there email? > > Postlogin scripting would work like Benjamin said. Another possibility > would be to check atime if you haven't disabled atime updates.atime is updated everytime I do a backup which is once a week.>protocol imap { ># ... >mail_executable = /full/path/to/loginscript.shI imagine I would need to put this in pop3 section as well?>#!/bin/sh >touch $HOME/.dovecot-lastlogin >exec /usr/libexec/dovecot/imapCan I just touch the dovecot.index instead? Also, I am bit confused. Why must the script exec imap? I imagine $HOME will contain the path to the home directory of the pop3/imap user that just successfully logged in? THanks Matt