1

Topic: user is removed from mail alias for no apparent reason

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.8
- Linux/BSD distribution name and version:  Debian 9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):  mysql
- Web server (Apache or Nginx): apache
- Manage mail accounts with iRedAdmin-Pro? yes, 2.9.0 (MySQL)
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

I manage 2 domains: iccs.gr, its-hellas.gr
Both domains have several mail aliases.
I have a user: panagiotis@iccs.gr who is member in the mail alias: bod@its-hellas.gr

When i am in the profile page of the user panagiotis@iccs.gr i can only see the mail aliases of iccs.gr (and not the mail aliases of its-hellas.gr)

The problem is the following:
Whenever, i press save changes in the profile page of panagiotis@iccs.gr, he is removed from the email aliases of its-hellas.gr

So, it is either a bug that not all mail aliases appear under the user's profile page, or it is a bug that the user is removed from the other domain mail aliases.

any help appreciated!

2

Re: user is removed from mail alias for no apparent reason

Did you migrate mail accounts to iRedMail? It's likely you didn't generate required SQL records in different SQL tables.

Check it with sql commands like below, replace '<mail>' by the real email address which disappeared after saving.

USE vmail;
SELECT address,forwarding FROM forwardings WHERE address='<mail>';

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

3

Re: user is removed from mail alias for no apparent reason

Hi,

the mail server was setup from the beginning with iredmail. There was no migration at any point.
The results of the command:
MariaDB [vmail]> SELECT address,forwarding FROM forwardings WHERE address='panagiotis@iccs.gr';
+-----------------------------+-----------------------------+
| address                     | forwarding                  |
+-----------------------------+-----------------------------+
| panagiotis@iccs.gr | panagiotis@iccs.gr |
+-----------------------------+-----------------------------+
1 row in set (0.00 sec)

Was there supposed to be more?

4

Re: user is removed from mail alias for no apparent reason

OK, it seems a bug of iRedAdmin-Pro, i will try to reproduce it and come back with a fix.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

5

Re: user is removed from mail alias for no apparent reason

nikos.frangakis wrote:

When i am in the profile page of the user panagiotis@iccs.gr i can only see the mail aliases of iccs.gr (and not the mail aliases of its-hellas.gr)

Bug confirmed.

nikos.frangakis wrote:

Whenever, i press save changes in the profile page of panagiotis@iccs.gr, he is removed from the email aliases of its-hellas.gr

I cannot reproduce this one.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

6

Re: user is removed from mail alias for no apparent reason

nikos.frangakis wrote:

When i am in the profile page of the user panagiotis@iccs.gr i can only see the mail aliases of iccs.gr (and not the mail aliases of its-hellas.gr)

This bug has been fixed in development edition of iRedAdmin-Pro, will be available in next release soon.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

7

Re: user is removed from mail alias for no apparent reason

I do see a similar problem when I try to save a forwarding or an alias - it says record saved but the field is empty. When I have a look in the database, I see that an entry in the forwarding table is made but with address and forwarding being the same instead of having the forwarding email address in the forwarding field.
Is this related to the bug you already found and when will be the release date for the update that fixes this behavior?

All the best

Mike

ZhangHuangbin wrote:
nikos.frangakis wrote:

When i am in the profile page of the user panagiotis@iccs.gr i can only see the mail aliases of iccs.gr (and not the mail aliases of its-hellas.gr)

This bug has been fixed in development edition of iRedAdmin-Pro, will be available in next release soon.

8

Re: user is removed from mail alias for no apparent reason

Sorry about this trouble.
We're preparing new iRedMail + iRedAdmin-Pro release. please be patient.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

9

Re: user is removed from mail alias for no apparent reason

Hello Zhang,
also pls double check what happens with forwardings that have destination domain similar to domain in iredmail database. Deleting that domain leads to deleting all forwardings where is that domain present. (not creating new topic, sry)

10

Re: user is removed from mail alias for no apparent reason

martin.rott wrote:

also pls double check what happens with forwardings that have destination domain similar to domain in iredmail database. Deleting that domain leads to deleting all forwardings where is that domain present. (not creating new topic, sry)

I don't quite understand this issue. Could you show me some sample sql records?

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

11 (edited by martin.rott 2018-12-03 23:43:04)

Re: user is removed from mail alias for no apparent reason

ZhangHuangbin wrote:
martin.rott wrote:

also pls double check what happens with forwardings that have destination domain similar to domain in iredmail database. Deleting that domain leads to deleting all forwardings where is that domain present. (not creating new topic, sry)

I don't quite understand this issue. Could you show me some sample sql records?

For some reasons I had one domain temporarily hosted in iredmail, which was disabled in iredmail sometime later (and forwarded to real mailserver). (old.com)
We had also another domain (new.com), but lot of users and aliases there had forwardings in database to mailserver old.com, batch created by manual SQL insertion like

'insert into forwardings(address, forwarding, domain, dest_domain, is_list, active) values ('targetuser@new.com', 'targetuser@old.com', 'new.com', 'old.com', 1, 1);'

Thing is - when I removed the old.com domain in iredadmin, all these forwardings (where old.com was present as dest_domain) were deleted. I think Iredadmin should not delete forwardings belonging under another domain(new.com) which destination domain is same as domain being currently deleted(old.com).
I've checked the code of Iredadmin, and here you have the problematic part:
/iredadmin/libs/sqllib/domain.py - line 626

       for tbl in ['forwardings', 'moderators']:
            conn.delete(tbl,
                        vars=sql_vars,
                        where='dest_domain IN $domains')

... for table forwardings adding sthg like

where='dest_domain IN $domains AND domain IN $domains'

should work probably fine

12

Re: user is removed from mail alias for no apparent reason

martin.rott wrote:

here you have the problematic part:

The logic is: If you host domain "example.com" on iRedMail server, then you remove it, all address *@example.com become invalid/dead. So we need to remove them also.

The problem of the logic of your suggestion is: if we remove domain but still keep the destination forwarding addresses, many addresses are invalid/dead, if you don't activate mail service for this remove domain somewhere again, emails sent to them will be always bounced/rejected.

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

13 (edited by martin.rott 2018-12-06 22:41:53)

Re: user is removed from mail alias for no apparent reason

ZhangHuangbin wrote:
martin.rott wrote:

here you have the problematic part:

The logic is: If you host domain "example.com" on iRedMail server, then you remove it, all address *@example.com become invalid/dead. So we need to remove them also.

The problem of the logic of your suggestion is: if we remove domain but still keep the destination forwarding addresses, many addresses are invalid/dead, if you don't activate mail service for this remove domain somewhere again, emails sent to them will be always bounced/rejected.

Sorry Zhang but I have to strongly disagree here - there's no logic about deleting forwardings belonging under different domain than I am deleting. That those mails will be bounced (if the domain/mailbox/whatever isn't created elsewhere) is the correct solution (so the administrator will get a hint about forgotten forwarding in different domain that is not working).

I found this out after few days when these forwardings weren't working without any notification from Iredmail or anything, because it just silently stopped forwarding.  Situations when this can happen are a bunch, for example mailserver migration, DNS switching..

Just imagine you have one Iredmail with two domains and you are moving one of those domains to another Iredmail server(both domains are variously forwarding emails between each other - pretty usual situation)..
Et cetera et cetera..

Regards,
Martin Rott

EDIT: to the primary question in this thread, I see there almost similar pattern in user SQL library - the SQL queries are totally unaware of the mail domain under which the user belongs, couldn't be this the root cause? Also - this leads to situation when different domain admin deletes database records belonging under another domain. Again, this can lead to consequences that are far more lethal than keeping some address in db which gets bounced if domain doesn't exist anymore. 

I absolutely love Iredmail, we bought Iredadmin-Pro and are looking forward for buying support just to keep at least some funding for this excellent opensource project, just trying to convince you that this is potentially really dangerous.

14

Re: user is removed from mail alias for no apparent reason

OK, i'm convinced. Suggested logic is better.

I will remove these lines in iRedAdmin-Pro which is used to delete records for forwarding destinations:

       for tbl in ['forwardings', 'moderators']:
            conn.delete(tbl,
                        vars=sql_vars,
                        where='dest_domain IN $domains')

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

15

Re: user is removed from mail alias for no apparent reason

martin.rott wrote:

EDIT: to the primary question in this thread, I see there almost similar pattern in user SQL library - the SQL queries are totally unaware of the mail domain under which the user belongs, couldn't be this the root cause?

The logic is slightly different than removing a domain, you just remove one user, but the domain is still hosted on your server. So we should remove this user from forwarding destination. isn't it?

martin.rott wrote:

I absolutely love Iredmail, we bought Iredadmin-Pro and are looking forward for buying support just to keep at least some funding for this excellent opensource project, just trying to convince you that this is potentially really dangerous.

Thank you very much. smile

----

Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee

16

Re: user is removed from mail alias for no apparent reason

ZhangHuangbin wrote:
martin.rott wrote:

EDIT: to the primary question in this thread, I see there almost similar pattern in user SQL library - the SQL queries are totally unaware of the mail domain under which the user belongs, couldn't be this the root cause?

The logic is slightly different than removing a domain, you just remove one user, but the domain is still hosted on your server. So we should remove this user from forwarding destination. isn't it?
?

From admin point of view is better to keep the domains separated - and, moreover, what about users doing self-service? Again, possibly dangerous behavior, there were reasons for creating that forwarding before, it shouldn't dissapear without notice..

Example:
I host 2 domains, one has a large mailing list where are people from both domains, moderators of the list have to be notified about user disappearing from the list. Keep the forwarding, send the bounce, don't invent sending moderators notification emails about user deletion in mailing list they moderate..

smile