1

Topic: mailbox not deleting

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9
- Deployed with iRedMail Easy or the downloadable installer? downloadable
- Linux/BSD distribution name and version: Centos7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Mailboxes are not deleting:

[root@mail iredapd]# python /var/www/iredadmin/tools/delete_mailboxes.py --delete-without-timestamp

* Delete old mailboxes (8 in total).
Traceback (most recent call last):
  File "/var/www/iredadmin/tools/delete_mailboxes.py", line 221, in <module>
    _dir = _ldif['homeDirectory'][0].lower().replace('//', '/')
KeyError: 'homeDirectory'

I do not use timestamps in mailbox names
The directory exists.

This is a sample database entry in Table deleted_mailboxes in database iredadmin (there are 8 entries) :
40     2019-02-13 09:51:55     hmurray@domain.net     domain.net     /var/vmail/vmail1/domain.net/h/m/u/hmurray/     mailadmin@cyg.net     2019-02-20

Thoughts?

----

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

2

Re: mailbox not deleting

jstewart wrote:

Traceback (most recent call last):
  File "/var/www/iredadmin/tools/delete_mailboxes.py", line 221, in <module>
    _dir = _ldif['homeDirectory'][0].lower().replace('//', '/')
KeyError: 'homeDirectory'

You can fix the script with patch below:

diff -r 46739b2de6e2 tools/delete_mailboxes.py
--- a/tools/delete_mailboxes.py Tue Feb 19 12:09:54 2019 +0800
+++ b/tools/delete_mailboxes.py Sun Feb 24 11:36:58 2019 +0800
@@ -218,8 +218,9 @@
                                   "(objectClass=mailUser)",
                                   ['homeDirectory'])
         for (_dn, _ldif) in _qr:
-            _dir = _ldif['homeDirectory'][0].lower().replace('//', '/')
-            all_maildirs.append(_dir)
+            if 'homeDirectory' in _ldif:
+                _dir = _ldif['homeDirectory'][0].lower().replace('//', '/')
+                all_maildirs.append(_dir)
     elif settings.backend in ['mysql', 'pgsql']:
         # WARNING: always append '/' in returned maildir path.
         _qr = conn_vmail('mailbox',

But, why does some mail user account not have LDAP attribute 'homeDirectory'? i'm afraid that there may be some data integrity issue with your LDAP data.

3

Re: mailbox not deleting

Thanks, that did the trick.

I was just looking at the LDAP homeDirectory entries of the mailboxes that were set for deletion, which all exist. I took a closer look, and I have a catchall for domain mail forwarding to a special account I created, so now the first entry in the LDAP users list has an entry in the "mail" field of just "@domain.com" and no homeDirectory entry.

4

Re: mailbox not deleting

That makes sense, please use the patch to fix it.