1

Topic: doveadm not working as expected run expunge command

==== Provide required information ====
- iRedMail version and backend (LDAP/MySQL/PGSQL): 0.8.0
- Linux/BSD distribution name and version: debian
- Any related log? Log is helpful for troubleshooting.
====

I upgraded to dovecot 2

doveadm expunge -u wells@thedarktimes.us mailbox Trash savedbefore 7d
     This does not work

doveadm expunge -u wells@thedarktimes.us mailbox Trash savedbefore 0d
     This does work, however it removes everything

doveadm search -A mailbox Trash savedbefore 0d
     This does not work

doveadm search -A mailbox Trash savedbefore 0d
     This does work

any dovecot command with a savedbefore doesn't seem to work

Troubleshooting:

(a)
I have a expire table in the vmail database, I check the time_stamp and it looked correct, showed in the past.

(b)
doveadm fetch -u wells@thedarktimes.us date.saved mailbox Trash 1
date.saved: 2012-05-23 13:21:42
I think this is suppose to be the oldest deleted email?
If so, this is wrong

(c)
deleted the expire table and recreated it

mysql -u root -p
use vmail;
CREATE TABLE expires ( username varchar(75) not null, mailbox varchar(255) not null, expire_stamp integer not null,  primary key (username, mailbox) );   

(d)
now the expire table doesn't populate when I delete emails (this is a problem)

(e)
added to dovecot.conf
mail_plugins = $mail_plugins expire
and under each protocol, mail_plugins expire

/etc/dovecot/dovecot-dict-expire.conf
connect = host=127.0.0.1 dbname=vmail user=vmail password=**********************

map {
  pattern = shared/expire/$user/$mailbox
  table = expires
  value_field = expire_stamp

  fields {
    username = $user
    mailbox = $mailbox
  }
}

/etc/dovecot/dovecot.conf


# Listen addresses.
#   - '*' means all available IPv4 addresses.
#   - '[::]' means all available IPv6 addresses.
# Use below setting to listen on all available addresses:
#listen = *, [::]
listen = *

#base_dir = /var/run/dovecot

# Enabled mail protocols.
protocols = pop3 imap sieve

# User/group who owns the message files:
mail_uid = 1001
mail_gid = 1001

# Assign uid to virtual users.
first_valid_uid = 1001
last_valid_uid = 1001

# Global Plugins
mail_plugins = $mail_plugins expire

# Logging. Reference: http://wiki2.dovecot.org/Logging
log_path = /var/log/dovecot.log
mail_debug = no
auth_verbose = no
auth_debug = no
auth_debug_passwords = no
# Possible values: no, plain, sha1.
auth_verbose_passwords = no

# SSL: Global settings.
# Refer to wiki site for per protocol, ip, server name SSL settings:
# http://wiki2.dovecot.org/SSL/DovecotConfiguration
ssl = yes
verbose_ssl = no
# ssl_cert = </etc/ssl/certs/iRedMail_CA.pem
# ssl_key = </etc/ssl/private/iRedMail.key

ssl_cert = </etc/ssl/certs/nm2.abgnetwork.net.pem
ssl_key = </etc/ssl/private/nm2.key
ssl_ca = </etc/ssl/certs/gd_bundle.pem

disable_plaintext_auth = no

# Mail location and mailbox format.
mail_location = maildir:/%Lh/Maildir/:INDEX=/%Lh/Maildir/

# Authentication related settings.
# Append this domain name if client gives empty realm.
#auth_default_realm =

# Authentication mechanisms.
auth_mechanisms = PLAIN LOGIN

service auth {
    unix_listener /var/spool/postfix/dovecot-auth {
        user = postfix
        group = postfix
        mode = 0666
    }
    unix_listener auth-master {
        user = vmail
        group = vmail
        mode = 0666
    }
}

# Virtual mail accounts.
userdb {
    args = /etc/dovecot/dovecot-mysql.conf
    driver = sql
}
passdb {
    args = /etc/dovecot/dovecot-mysql.conf
    driver = sql
}

plugin {
    auth_socket_path = /var/run/dovecot/auth-master

    quota = dict:user::proxy::quotadict
    quota_rule = *:storage=1G
    #quota_rule2 = *:messages=0
    #quota_rule3 = Trash:storage=1G
    #quota_rule4 = Junk:ignore

    # Quota warning.
    # If user suddenly receives a huge mail and the quota jumps from
    # 85% to 95%, only the 95% script is executed.
    quota_warning = storage=85%% quota-warning 85 %u
    quota_warning2 = storage=90%% quota-warning 90 %u
    quota_warning3 = storage=95%% quota-warning 95 %u

    # Plugin: autocreate. Create and subscribe to default IMAP folders.
    autocreate = INBOX
    autocreate2 = Sent
    autocreate3 = Trash
    autocreate4 = Drafts
    autocreate5 = Junk
    autosubscribe = INBOX
    autosubscribe2 = Sent
    autosubscribe3 = Trash
    autosubscribe4 = Drafts
    autosubscribe5 = Junk

    # Plugin: expire.
    expire = Trash 7 Trash/* 7 Junk 30 Sent 30
    expire_dict = proxy::expire

    # ACL and share folder
    acl = vfile
    acl_shared_dict = proxy::acl

    # Pigeonhole managesieve service.
    # Reference: http://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration
    # Per-user sieve settings.
    sieve_dir = /%Lh/sieve
    sieve = /%Lh/sieve/dovecot.sieve

    # Global sieve settings.
    sieve_global_dir = /var/vmail/sieve
    sieve_global_path = /var/vmail/sieve/dovecot.sieve
    #sieve_before =
    #sieve_after =
}

service quota-warning {
    executable = script /usr/local/bin/dovecot-quota-warning.sh
    unix_listener quota-warning {
        user = vmail
        group = vmail
        mode = 0660
    }
}

service dict {
    unix_listener dict {
        mode = 0660
        user = vmail
        group = vmail
    }
}

dict {
    # expire = db:/var/lib/dovecot/expire/expire.db
    expire = mysql:/etc/dovecot/dovecot-dict-expire.conf
    quotadict = mysql:/etc/dovecot/dovecot-used-quota.conf
    acl = mysql:/etc/dovecot/dovecot-share-folder.conf
}

protocol lda {
    # Reference: http://wiki2.dovecot.org/LDA
    mail_plugins = quota sieve autocreate expire
    auth_socket_path = /var/run/dovecot/auth-master
    log_path = /var/log/sieve.log
    lda_mailbox_autocreate = yes
    postmaster_address = root
}
protocol imap {
    imap_client_workarounds = tb-extra-mailbox-sep
    mail_plugins = quota imap_quota autocreate expire
}
protocol pop3 {
    mail_plugins = quota expire
    pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
    pop3_uidl_format = %08Xu%08Xv
}
namespace {
    type = private
    separator = /
    prefix =
    #location defaults to mail_location.
    inbox = yes
}

namespace {
    type = shared
    separator = /
    prefix = Shared/%%u/
    location = maildir:/%%Lh/Maildir/:INDEX=/%%Lh/Maildir/Shared/%%u
    # this namespace should handle its own subscriptions or not.
    subscriptions = yes
    list = children
}

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: doveadm not working as expected run expunge command

darth_wells wrote:

doveadm expunge -u wells@thedarktimes.us mailbox Trash savedbefore 7d
     This does not work

doveadm search -A mailbox Trash savedbefore 0d
     This does not work

- iRedMail doesn't support/enable Dovecot expire plugin by default.
- Perform the same commands (which not work) again with '-D' option and paste output here.

# doveadm -D ...

3

Re: doveadm not working as expected run expunge command

doveadm -D search -u test@maineplastics.com mailbox Trash savedbefore 7d
doveadm(root): Debug: Loading modules from directory: /usr/lib/dovecot/modules
doveadm(root): Debug: Module loaded: /usr/lib/dovecot/modules/lib20_expire_plugin.so
doveadm(root): Debug: Loading modules from directory: /usr/lib/dovecot/modules/doveadm
doveadm(root): Debug: Skipping module doveadm_acl_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_acl_plugin.so: undefined symbol: acl_user_module (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Module loaded: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_expire_plugin.so
doveadm(root): Debug: Skipping module doveadm_quota_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_quota_plugin.so: undefined symbol: quota_user_module (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Skipping module doveadm_zlib_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_zlib_plugin.so: undefined symbol: i_stream_create_deflate (this is usually intentional, so just ignore this message)
doveadm(root): Debug: expire: Iterating only a single user, ignoring expire database
doveadm(test@maineplastics.com): Debug: Added userdb setting: plugin/quota_rule=*:bytes=262144000
doveadm(test@maineplastics.com): Debug: Effective uid=1001, gid=1001, home=/var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07/
doveadm(test@maineplastics.com): Debug: Namespace : type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir://var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir/:INDEX=//var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir/
doveadm(test@maineplastics.com): Debug: maildir++: root=//var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir, index=, control=, inbox=//var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir, alt=
doveadm(test@maineplastics.com): Debug: Namespace : type=shared, prefix=Shared/%u/, sep=/, inbox=no, hidden=no, list=children, subscriptions=yes location=maildir:/%Lh/Maildir/:INDEX=/%Lh/Maildir/Shared/%u
doveadm(test@maineplastics.com): Debug: shared: root=/var/run/dovecot, index=, control=, inbox=, alt=

=============

doveadm -D search -u test@maineplastics.com mailbox Trash savedbefore 0d
doveadm(root): Debug: Loading modules from directory: /usr/lib/dovecot/modules
doveadm(root): Debug: Module loaded: /usr/lib/dovecot/modules/lib20_expire_plugin.so
doveadm(root): Debug: Loading modules from directory: /usr/lib/dovecot/modules/doveadm
doveadm(root): Debug: Skipping module doveadm_acl_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_acl_plugin.so: undefined symbol: acl_user_module (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Module loaded: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_expire_plugin.so
doveadm(root): Debug: Skipping module doveadm_quota_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_quota_plugin.so: undefined symbol: quota_user_module (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Skipping module doveadm_zlib_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_zlib_plugin.so: undefined symbol: i_stream_create_deflate (this is usually intentional, so just ignore this message)
doveadm(root): Debug: expire: Iterating only a single user, ignoring expire database
doveadm(test@maineplastics.com): Debug: Added userdb setting: plugin/quota_rule=*:bytes=262144000
doveadm(test@maineplastics.com): Debug: Effective uid=1001, gid=1001, home=/var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07/
doveadm(test@maineplastics.com): Debug: Namespace : type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir://var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir/:INDEX=//var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir/
doveadm(test@maineplastics.com): Debug: maildir++: root=//var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir, index=, control=, inbox=//var/vmail/vmail1/maineplastics.com/t/e/s/test-2011.12.06.09.50.07//Maildir, alt=
doveadm(test@maineplastics.com): Debug: Namespace : type=shared, prefix=Shared/%u/, sep=/, inbox=no, hidden=no, list=children, subscriptions=yes location=maildir:/%Lh/Maildir/:INDEX=/%Lh/Maildir/Shared/%u
doveadm(test@maineplastics.com): Debug: shared: root=/var/run/dovecot, index=, control=, inbox=, alt=
5429ef33c1f6bc4f19190000527b8ca5 1
5429ef33c1f6bc4f19190000527b8ca5 2
5429ef33c1f6bc4f19190000527b8ca5 3
5429ef33c1f6bc4f19190000527b8ca5 4
5429ef33c1f6bc4f19190000527b8ca5 5
5429ef33c1f6bc4f19190000527b8ca5 6
5429ef33c1f6bc4f19190000527b8ca5 7
5429ef33c1f6bc4f19190000527b8ca5 8
5429ef33c1f6bc4f19190000527b8ca5 9
5429ef33c1f6bc4f19190000527b8ca5 10
5429ef33c1f6bc4f19190000527b8ca5 11
5429ef33c1f6bc4f19190000527b8ca5 12
5429ef33c1f6bc4f19190000527b8ca5 13
5429ef33c1f6bc4f19190000527b8ca5 14
5429ef33c1f6bc4f19190000527b8ca5 15
5429ef33c1f6bc4f19190000527b8ca5 16
5429ef33c1f6bc4f19190000527b8ca5 17
5429ef33c1f6bc4f19190000527b8ca5 18
5429ef33c1f6bc4f19190000527b8ca5 19
5429ef33c1f6bc4f19190000527b8ca5 20
5429ef33c1f6bc4f19190000527b8ca5 21
5429ef33c1f6bc4f19190000527b8ca5 22
5429ef33c1f6bc4f19190000527b8ca5 23
5429ef33c1f6bc4f19190000527b8ca5 24
5429ef33c1f6bc4f19190000527b8ca5 25
5429ef33c1f6bc4f19190000527b8ca5 26
5429ef33c1f6bc4f19190000527b8ca5 27
5429ef33c1f6bc4f19190000527b8ca5 28
5429ef33c1f6bc4f19190000527b8ca5 29
5429ef33c1f6bc4f19190000527b8ca5 30
5429ef33c1f6bc4f19190000527b8ca5 31

4

Re: doveadm not working as expected run expunge command

The settings in your dovecot.conf:

# Plugin: expire.
    expire = Trash 7 Trash/* 7 Junk 30 Sent 30

Did you try below mentioned in Dovecot-2 wiki:

plugin {
  expire = Trash
  expire2 = Trash/*
  expire3 = Spam
}