1

Topic: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.5.1
- Deployed with iRedMail Easy or the downloadable installer? Downloadable
- Linux/BSD distribution name and version: RHEL 8
- 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.
====

We have hundreds of domains, several domains forward all their email to one specific domain.  For reference, I will use example.com.

About 75 individual accounts, across 12 or so different domains, all forward to example.com.  We are moving example.com to a different email server, so when we removed example.com from the original email server, ALL of the forwards were also removed. 

Is this by design?
Is there a way to restore those forwards?
Is there a way to disable this functionality in the future?

----

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

2

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

well if the domain is not hosted in the server anymore, it can't handle forwards, and forwards are children of the domain, so if the domain gets deleted, the children get aswell since they won't be able to work

i guess that you are responsible for manageing all the domains and stuff and so  have a backup of the database to restore it

3

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

Cthulhu wrote:

well if the domain is not hosted in the server anymore, it can't handle forwards, and forwards are children of the domain, so if the domain gets deleted, the children get aswell since they won't be able to work

i guess that you are responsible for manageing all the domains and stuff and so  have a backup of the database to restore it


I hope it can handle forwards.  The MX records have changed for example.com to point to the new email server. 

It just seems wrong that different users from different domains forwarding to example.com would be removed.  It seems the forwarding would be left alone if the forwarding was from completely different domains.

4

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

then restore backup of the mail accounts filtered by only containing example.com as forward domain, and everything should be fine again

5 (edited by Cthulhu 2022-03-09 02:44:57)

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

restore backup of vmail database to a new database of your choice, then:

SELECT * FROM vmailrestore.forwardings WHERE vmailrestore.forwardings.dest_domain ="example.com";


there you get all columns where the destination of the forwarding is example.com

export those to a sql import file (dont use the column id since it is unique and autoincrement) and import it to your actual database and all should work again


Edit:

@ZhangHuangbin

I agree that just deleting a domain should not cascade all references in vmail.forwardings that point to the deleted domain, since it doesn't matter if the forwarded domain is locally hosted or not, either remove that completely or make it a checkbox with a warning like "delete all forwardings pointing to that domain aswell" so ppl have the choice to do so if they want

6

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

@Cthulu

The SQL you suggested worked well, thank you. 

Also thank you for the note to ZhangHuangbin.  Thankfully, the example.com in question was small and not that many forwards.  We have, for the time being, stopped balancing our email server load between machines.  Hope to hear back from ZhangHuangbin soon. big_smile

7

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

This issue has been fixed moment ago, and will be available in next iRedAdmin-Pro release.
Here's the patch for iRedAdmin-Pro-SQL-5.0. iRedAdmin-Pro customers (with valid license) can contact us (https://www.iredmail.org/contact.html) to get a patched version.

diff --git a/libs/sqllib/domain.py b/libs/sqllib/domain.py
index f9dd4573..44fd0508 100644
--- a/libs/sqllib/domain.py
+++ b/libs/sqllib/domain.py
@@ -680,21 +680,6 @@ def delete_domains(domains,
                         vars=sql_vars,
                         where='domain IN $domains')
 
-        # Delete destination domain name.
-        for tbl in ['forwardings', 'moderators']:
-            conn.delete(tbl,
-                        vars=sql_vars,
-                        where='dest_domain IN $domains')
-
-        # Introduced AFTER iRedMail-1.3.2.
-        for tbl in ['maillist_owners']:
-            try:
-                conn.delete(tbl,
-                            vars=sql_vars,
-                            where='domain IN $domains OR dest_domain IN $domains')
-            except:
-                pass
-
         # Delete alias domain
         conn.delete('alias_domain',
                     vars=sql_vars,

8

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

Thanks to all users in this thread for the report and help. big_smile

9

Re: iRedAdmin-Pro - Forwards deleted when domain deleted. HELP!

Thank you!!!