[Dovecot] mailbox not acceced

Benjamin R. Haskell dovecot at benizi.com
Mon Feb 11 18:36:54 EET 2008


On Mon, 11 Feb 2008, Hugo Monteiro wrote:

> Osvaldo Alvarez Pozo wrote:
>> Hi
>> I wonder how can I know if a mailbox is not beeing consulted. I mean I
>> have severals mailboxs but I know some account are not used. I like to
>> know how to determine wich mail accounts are not beeing used. Is there
>> any way in dovecot to know the las  time a user loged in to dovecot?
>> 
>> Thanks
>>
>> 
>
> I'm using dovecot's ability to use "pre execution" scripts.
>
> Basically i have in my imap protocol definition in dovecot.conf an alternate 
> mail_executable
>
> protocol imap {
> ...
> mail_executable = /usr/local/bin/imap-wrapper.sh
> ...
> }
>
> And that executable has the following:
>
> ---- snip ----
> #!/bin/sh
>
> # Filesystem based timestamp in user's home directory and protocol used
> echo imap > /var/spool/lastlogin/$UID
>
> # Finally execute the imap/pop3 binary. If you use both, you'll need two 
> scripts.
> exec /usr/lib/dovecot/imap
> ---- snip ----
>
>
> I echo the protocol into the file because i have both pop and imap available 
> to my users and this way i can keep track when was the last time they 
> accessed their mailbox (ls -l /var/spool/lastlogin/username) and which 
> protocol they used in that access (cat /var/spool/lastlogin/username).
>
>
> There are inumerous possibilities of course.
>

For a summary of recent-past emails about this, see: 
http://dovecot.org/list/dovecot/2007-November/027148.html

To make the script in this email work for both POP3 and IMAP:

$ cat /root/dovecot-login.sh
#!/bin/sh
PROTO=`basename $0`
echo $PROTO > /var/spool/lastlogin/$UID
exec /usr/libexec/dovecot/$PROTO

$ ln -s /root/dovecot-login.sh /root/imap
$ ln -s /root/dovecot-login.sh /root/pop3

In dovecot.conf:

protocol imap {
...
mail_executable = /root/imap
...
}

protocol pop3 {
...
mail_executable = /root/pop3
...
}


Best,
Ben


More information about the dovecot mailing list