1

Topic: Greylisting for alias domains in iRedAdmin-Pro

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

Hi,

When disabling greylisting for a particular domain through iRedAdmin-Pro-SQL-4.1.2 there are not any rules created for alias domains.

Is this a feature that could be added or am I missing something that iRedmail does in the background for this? I realised this after a report of slow email delivery and found that the emails had infact been greylisted even though we thought it had been disabled in iRedAdmin.

I have since used the tools/greylisting_admin.py to disable greylisting for the alias domains.

Many thanks,
Nick

----

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

2

Re: Greylisting for alias domains in iRedAdmin-Pro

Seems a bug of the iRedAPD greylisting plugin, i will check and fix it later.

Created an issue to help track this bug:
https://github.com/iredmail/iRedAPD/issues/1

3

Re: Greylisting for alias domains in iRedAdmin-Pro

Hi Nick,

Could you please try this patch for iRedAPD-3.4? Tested locally and it should fix your issue.

diff --git a/plugins/greylisting.py b/plugins/greylisting.py
index 69633fa..e3fab15 100644
--- a/plugins/greylisting.py
+++ b/plugins/greylisting.py
@@ -18,6 +18,10 @@ from libs import SMTP_ACTIONS, ACCOUNT_PRIORITIES
 from libs import utils, ipaddress, dnsspf
 import settings
 
+if settings.backend == 'ldap':
+    from libs.ldaplib.conn_utils import get_alias_target_domain
+else:
+    from libs.sql import get_alias_target_domain
 
 # Return 4xx with greylisting message to Postfix.
 action_greylisting = SMTP_ACTIONS['greylisting'] + ' ' + settings.GREYLISTING_MESSAGE
@@ -342,6 +346,14 @@ def restriction(**kwargs):
     policy_senders = utils.get_policy_addresses_from_email(mail=sender)
     policy_senders += [client_address]
 
+    # If recipient_domain is an alias domain name, we should check the target
+    # domain.
+    conn_vmail = kwargs['conn_vmail']
+    alias_target_rcpt_domain = get_alias_target_domain(alias_domain=recipient_domain, conn=conn_vmail)
+    if alias_target_rcpt_domain:
+        _addr = recipient.split('@', 1)[0] + '@' + alias_target_rcpt_domain
+        policy_recipients += utils.get_policy_addresses_from_email(mail=_addr)
+
     if utils.is_ipv4(client_address):
         # Add wildcard ip address: xx.xx.xx.*.
         policy_senders += client_address.rsplit('.', 1)[0] + '.*'

4

Re: Greylisting for alias domains in iRedAdmin-Pro

Hi Zhang,

Many thanks for the quick patch, appears to be working as expected.

5

Re: Greylisting for alias domains in iRedAdmin-Pro

Thanks for the feedback. New iRedAPD version is tagged: v3.5.