1

Topic: Fail to create account after remove alias with this same address

==== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7
- Linux/BSD distribution name and version: Debian 9.0
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):  MySQL
- 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.
====
Hi,
i have deleted one alias admin@example.com and after that i want to create new account admin@example.com but iredadmin panel give me error message "Account already exists". I've checked sql for admin@example.com and i found entry in forwardings table. After delete this entry i was able to create such account.

----

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

2

Re: Fail to create account after remove alias with this same address

Which version of iRedAdmin-Pro are you running?

3

Re: Fail to create account after remove alias with this same address

ZhangHuangbin wrote:

Which version of iRedAdmin-Pro are you running?

2.7.0 MySQL

4

Re: Fail to create account after remove alias with this same address

lamagra wrote:

i have deleted one alias admin@example.com and after that i want to create new account admin@example.com but iredadmin panel give me error message "Account already exists". I've checked sql for admin@example.com and i found entry in forwardings table. After delete this entry i was able to create such account.

About "delete one alias admin@example.com", did you delete a mail alias account, or a per-user alias address?
Could you please show us step-by-step instruction?

5

Re: Fail to create account after remove alias with this same address

ZhangHuangbin wrote:
lamagra wrote:

i have deleted one alias admin@example.com and after that i want to create new account admin@example.com but iredadmin panel give me error message "Account already exists". I've checked sql for admin@example.com and i found entry in forwardings table. After delete this entry i was able to create such account.

About "delete one alias admin@example.com", did you delete a mail alias account, or a per-user alias address?
Could you please show us step-by-step instruction?

1. Add mail alias test@example.com with one member test2@example.com
2. Delete mail alias test@example.com (in iredmail panel alias was deleted succesfull)
3. Try to add mail user test@example.com

6

Re: Fail to create account after remove alias with this same address

Fixed. Here's patch for iRedAdmin-Pro-SQL-2.7.0:

diff -r 61693ac5d18c libs/sqllib/alias.py
--- a/libs/sqllib/alias.py    Fri Jul 28 00:27:05 2017 +0800
+++ b/libs/sqllib/alias.py    Sun Jul 30 17:08:14 2017 +0800
@@ -160,6 +160,10 @@
         conn.delete('alias',
                     vars=sql_vars,
                     where='address IN $accounts')
+
+        conn.delete('forwardings',
+                    vars=sql_vars,
+                    where='address IN $accounts OR forwarding IN $accounts')
     except Exception, e:
         return (False, repr(e))
 

7

Re: Fail to create account after remove alias with this same address

To clean up dead mail alias accounts, you can run SQL commands below:

USE vmail;
DELETE FROM forwardings WHERE is_list=1 AND address NOT IN (SELECT address FROM alias);

8

Re: Fail to create account after remove alias with this same address

ZhangHuangbin wrote:

Fixed. Here's patch for iRedAdmin-Pro-SQL-2.7.0:

diff -r 61693ac5d18c libs/sqllib/alias.py
--- a/libs/sqllib/alias.py    Fri Jul 28 00:27:05 2017 +0800
+++ b/libs/sqllib/alias.py    Sun Jul 30 17:08:14 2017 +0800
@@ -160,6 +160,10 @@
         conn.delete('alias',
                     vars=sql_vars,
                     where='address IN $accounts')
+
+        conn.delete('forwardings',
+                    vars=sql_vars,
+                    where='address IN $accounts OR forwarding IN $accounts')
     except Exception, e:
         return (False, repr(e))
 

Now everything works fine. Thx.