最後更新: 2019-08-23
Last Login Plugin
update user's last-login timestamp in the configured dictionary
* Requires v2.2.14+
* If enabled globally, it'll also update the timestamp whenever new mails are delivered via lda/lmtp
or when doveadm is run for the user. (所以不能 Globally Enable 它 !!)
[1] DB Schema
CREATE TABLE IF NOT EXISTS `last_login` ( `username` VARCHAR(255) NOT NULL DEFAULT '', `domain` VARCHAR(255) NOT NULL DEFAULT '', `last_login` INT(11) DEFAULT NULL, PRIMARY KEY (`username`), INDEX (domain) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
[2] Dovecot 設定
protocol imap { mail_plugins = $mail_plugins last_login } protocol pop3 { mail_plugins = $mail_plugins last_login } dict { ... lastlogin = mysql:/etc/dovecot/dovecot-last-login.conf } plugin { last_login_dict = proxy::lastlogin last_login_key = last-login/%u/%d }
last_login_key <= setting
[3] Dictionary
/etc/dovecot/dovecot-last-login.conf
connect = host=127.0.0.1 port=3306 dbname=vmail user=vmail password=my_secret_password map { pattern = shared/last-login/$user/$domain table = last_login value_field = last_login value_type = uint fields { username = $user domain = $domain } }
chown dovecot:dovecot /etc/dovecot/dovecot-last-login.conf
chmod 0400 /etc/dovecot/dovecot-last-login.conf