1

Topic: How-to clean Trash and Spam folders from all users?

==== Required information ====
- iRedMail version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Linux/BSD distribution name and version:
- Related log if you're reporting an issue:
====Hello people,

I'm looking for a way to clean/empty all trash and spam folders from my users. A lot of them are leaving messages on those folders for many many days using bytes that they don't need.

I try to use the doveadm expunge command but nothing happen (I receive a message that the user don't exist).

Any clue about it?

Thanks

==== Required information ====
- iRedMail version: 0-8-4
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Linux/BSD distribution name and version: Debian 7 - Linux 3.9.3-x86
- Related log if you're reporting an issue:
====

----

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

2

Re: How-to clean Trash and Spam folders from all users?

Could you please show us detailed commands you run and their output? Also, please run it again with '-D' option for 'doveadm', we need debug message for troubleshooting.

3

Re: How-to clean Trash and Spam folders from all users?

ZhangHuangbin wrote:

Could you please show us detailed commands you run and their output? Also, please run it again with '-D' option for 'doveadm', we need debug message for troubleshooting.

Hi Zhang, thank you for your reply.

The commands are:

# doveadm expunge -u representante@llteixeira.com.br mailbox Trash savedbefore 1d
doveadm(representante@llteixeira.com.br): Fatal: User doesn't exist

and if -D option:

# doveadm -D expunge -u representante@llteixeira.com.br mailbox Trash savedbefore 1d
doveadm(root): Debug: Loading modules from directory: /usr/lib/dovecot/modules
doveadm(root): Debug: Module loaded: /usr/lib/dovecot/modules/lib10_quota_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: Skipping module doveadm_expire_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_expire_plugin.so: undefined symbol: expire_set_deinit (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Module loaded: /usr/lib/dovecot/modules/doveadm/lib10_doveadm_quota_plugin.so
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: Skipping module doveadm_fts_plugin, because dlopen() failed: /usr/lib/dovecot/modules/doveadm/lib20_doveadm_fts_plugin.so: undefined symbol: fts_backend_rescan (this is usually intentional, so just ignore this message)
doveadm(representante@llteixeira.com.br): Fatal: User doesn't exist

Again, thank you for your support.

4

Re: How-to clean Trash and Spam folders from all users?

Could you please show me content of file /etc/dovecot/dovecot-ldap.conf? WARNING: Remove/hide/replace password before pasting.

5

Re: How-to clean Trash and Spam folders from all users?

Hello Zhang,

This is the content of dovecot-ldap.conf file:

hosts           = 127.0.0.1:389
ldap_version    = 3
auth_bind       = yes
dn              = cn=vmail,dc=btechost,dc=com,dc=br
dnpass          =
base            = o=domains,dc=btechost,dc=com,dc=br
scope           = subtree
deref           = never

# Below two are required by command 'doveadm mailbox ...'
iterate_attrs   = mail=user
iterate_filter  = (&(objectClass=mailUser)(accountStatus=active)(enabledService=mail))
user_filter     = (&(objectClass=mailUser)(accountStatus=active)(enabledService=mail)(enabledService=%Ls%Lc)(|(mail=%u)
user_attrs      = mail=user,homeDirectory=home,=mail=maildir:~/Maildir/,mailQuota=quota_rule=*:bytes=%$
pass_filter     = (&(objectClass=mailUser)(accountStatus=active)(enabledService=mail)(enabledService=%Ls%Lc)(|(mail=%u)
pass_attrs      = mail=user,userPassword=password
default_pass_scheme = CRYPT

6

Re: How-to clean Trash and Spam folders from all users?

I setup an VM with default iRedMail settings, has same dovecot-ldap.conf, and it works for me here.  Check below command output, you see it finds the correct maildir path.

# doveadm -D expunge -u postmaster@a.cn mailbox Trash savedbefore 1d
doveadm(root): Debug: Loading modules from directory: /usr/lib64/dovecot
doveadm(root): Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
doveadm(root): Debug: Loading modules from directory: /usr/lib64/dovecot/doveadm
doveadm(root): Debug: Skipping module doveadm_acl_plugin, because dlopen() failed: /usr/lib64/dovecot/doveadm/lib10_doveadm_acl_plugin.so: undefined symbol: acl_user_module (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Skipping module doveadm_expire_plugin, because dlopen() failed: /usr/lib64/dovecot/doveadm/lib10_doveadm_expire_plugin.so: undefined symbol: expire_set_lookup (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Module loaded: /usr/lib64/dovecot/doveadm/lib10_doveadm_quota_plugin.so
doveadm(root): Debug: Skipping module doveadm_zlib_plugin, because dlopen() failed: /usr/lib64/dovecot/doveadm/lib10_doveadm_zlib_plugin.so: undefined symbol: i_stream_create_deflate (this is usually intentional, so just ignore this message)
doveadm(root): Debug: Skipping module doveadm_fts_plugin, because dlopen() failed: /usr/lib64/dovecot/doveadm/lib20_doveadm_fts_plugin.so: undefined symbol: fts_list_backend (this is usually intentional, so just ignore this message)
doveadm(postmaster@a.cn): Debug: Added userdb setting: mail=maildir:~/Maildir/
doveadm(postmaster@a.cn): Debug: Added userdb setting: plugin/quota_rule=*:bytes=104857600
doveadm(postmaster@a.cn): Debug: Effective uid=2000, gid=2000, home=/var/vmail/vmail1/a.cn/p/o/s/postmaster-2014.04.11.22.37.48/
doveadm(postmaster@a.cn): Debug: Quota root: name=user backend=dict args=:proxy::quotadict
doveadm(postmaster@a.cn): Debug: Quota rule: root=user mailbox=* bytes=104857600 messages=0
doveadm(postmaster@a.cn): Debug: Quota warning: bytes=89128960 (85%) messages=0 reverse=no command=quota-warning 85 postmaster@a.cn
doveadm(postmaster@a.cn): Debug: Quota warning: bytes=94371840 (90%) messages=0 reverse=no command=quota-warning 90 postmaster@a.cn
doveadm(postmaster@a.cn): Debug: Quota warning: bytes=99614720 (95%) messages=0 reverse=no command=quota-warning 95 postmaster@a.cn
doveadm(postmaster@a.cn): Debug: dict quota: user=postmaster@a.cn, uri=proxy::quotadict, noenforcing=0
doveadm(postmaster@a.cn): Debug: Namespace : type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:~/Maildir/
doveadm(postmaster@a.cn): Debug: maildir++: root=/var/vmail/vmail1/a.cn/p/o/s/postmaster-2014.04.11.22.37.48//Maildir, index=, control=, inbox=/var/vmail/vmail1/a.cn/p/o/s/postmaster-2014.04.11.22.37.48//Maildir, alt=
doveadm(postmaster@a.cn): 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(postmaster@a.cn): Debug: shared: root=/var/run/dovecot, index=, control=, inbox=, alt=

So the question is, do you use the correct email address in command? or, does it work if you use '*@domain.com'? For example:

# doveadm expunge -u *@a.cn mailbox Trash savedbefore 1d

7

Re: How-to clean Trash and Spam folders from all users?

Hi Zhang,

Thank you for your effort with my case.

I've checked the email address and they're correct. When I use the command doveadm expunge -u *@a.cn mailbox Trash savedbefore 1d for any domain hosted, I receive the same message. Look that:

:# doveadm expunge -u *@llteixeira.com.br mailbox Trash savedbefore 1d
doveadm(adm@llteixeira.com.br): Info: User no longer exists, skipping
doveadm(comercial@llteixeira.com.br): Info: User no longer exists, skipping
doveadm(contato@llteixeira.com.br): Info: User no longer exists, skipping
doveadm(gerencia@llteixeira.com.br): Info: User no longer exists, skipping
doveadm(llteixeira@llteixeira.com.br): Info: User no longer exists, skipping
doveadm(representante@llteixeira.com.br): Info: User no longer exists, skipping
doveadm(rosana@llteixeira.com.br): Info: User no longer exists, skipping

When you can see in the attachment, all emails exist.

In the other hand, when I use the command doveadm -D expunge -u postmaster@btechost.com.br mailbox Trash savedbefore 1d I have success. Maybe the command runs with the "btechost.com.br" because this is the main domain of my installation. I reall don't know.

Again, another clue? wink

Thank you so much!

Post's attachments

shot_ 2014-04-11 at 08.32.40.png
shot_ 2014-04-11 at 08.32.40.png 46.32 kb, file has never been downloaded. 

shot_ 2014-04-11 at 08.33.16.png
shot_ 2014-04-11 at 08.33.16.png 28.92 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

8

Re: How-to clean Trash and Spam folders from all users?

Oh, i guess i found the problem.

pmichelazzo wrote:

doveadm(adm@llteixeira.com.br): Info: User no longer exists, skipping

Does this user have attribute/value pair: enabledService=doveadm? If not, please add it and try again.

Is your server upgraded from iRedMail-0.7.4 or even earlier version? 'enabledService=doveadm' is mentioned in iRedMail upgrade tutorial of upgrading 0.7.4 to 0.8.0:
http://www.iredmail.org/wiki/index.php? … by_Doveadm

9

Re: How-to clean Trash and Spam folders from all users?

Hi Zhang,

Thanks again, but, where can I check/put this option?

I never upgrade my version. This is the first installation of Iredmail

Thank you!

10

Re: How-to clean Trash and Spam folders from all users?

You already logged in to phpLDAPadmin and show us mail users under your domain, just click the mail account, it will show you all LDAP data of this user in the right panel of phpLDAPadmin. You can see LDAP attribute name "enabledService" (and many others) and its values.

If you have iRedAdmin-Pro-LDAP installed, go to user profile page of this user, under tab "General", you can see a link "Export account to LDIF", click it and it will show us full LDIF data of this user.

11

Re: How-to clean Trash and Spam folders from all users?

Hi Zhang,

You're right! I put the doveadm option in my LDAP and everything is fine now. A big thank you for this.

But... now, how can I give this option for every account? I have almost 1000 there wink

Regards!

12

Re: How-to clean Trash and Spam folders from all users?

Easy: http://www.iredmail.org/wiki/index.php? … by_Doveadm

13

Re: How-to clean Trash and Spam folders from all users?

Dear Zhang,

Thank you so much for your help. I solved my problems with the doveadm.

All the best!