Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have Dovecot 1.2.12 running on Ubuntu Server 10.10 and I'm trying to get a post-login script to log the date and time that the users access their IMAP mailbox. I've read the Dovecot wiki and added the following to dovecot.conf:

mail_executable: /usr/lib/dovecot/logon.sh /usr/lib/dovecot/imap

The logon.sh script is pretty basic (logging all user access to a single file, plus the touch method given by the wiki):

#!/bin/sh 
dt=$(date) 
echo $USER $dt >> /opt/logon 
touch ~/.last_login

With the mail_executable line as above, the script runs successfully when a user attempts to log in, but access to the IMAP server fails (clients are Roundcube webmail running on the same box, and MS Outlook). /var/log/mail.log isn't very revealing. The login is logged normally and then nothing follows it:

dovecot: imap-login: Login: user=<username>, method=PLAIN, rip=172.16.2.26, lip=172.16.2.26, secured

Putting the script after the IMAP executable, like this:

mail_executable: /usr/lib/dovecot/imap /usr/lib/dovecot/logon.sh

results in normal IMAP functionality, but the script doesn't run.

Output of dovecot -n:

# 1.2.12: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.35-32-server x86_64 Ubuntu 10.10 ext4
log_timestamp: %Y-%m-%d %H:%M:%S
disable_plaintext_auth: no
login_dir: /var/run/dovecot/login
login_executable: /usr/lib/dovecot/imap-login
mail_privileged_group: mail
mail_location: maildir:/home/%u/Maildir
mail_debug: yes
mbox_write_locks: fcntl dotlock
mail_executable: /usr/lib/dovecot/logon.sh /usr/lib/dovecot/imap
auth default:
  passdb:
    driver: pam
  userdb:
    driver: passwd

I feel like I'm missing something obvious here. Please help! Thanks in advance.

share|improve this question

closed as off-topic by Luis Aug 8 '13 at 9:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Ubuntu Server 10.10 is not end of life? –  Radu Rădeanu Aug 7 '13 at 11:20

1 Answer 1

up vote 0 down vote accepted

The documentation says you to change the mail_executable parameter.

mail_executable: /usr/lib/dovecot/logon.sh

and the IMAP/POP binary is called from within your script. Check the following comment in the document

# Finally execute the imap/pop3 binary. If you use both, you'll need two scripts.
exec /usr/local/libexec/dovecot/imap "$@"

I am not sure if version 1.x supports specifying multiple scripts via mail_executable

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.