1

Topic: Disable and enable SMTP for an domain

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release):  1.6.8
- Deployed with iRedMail Easy or the downloadable installer?: installer
- Linux/BSD distribution name and version: Alma 9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): Mysql
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro?: Yes
====


Hi!
I need to suspend the smtp services for a domain that not payed but without stop recives.

With API parameter "removeService" I disabled smtp/smtpsecured to users of that domain. But, to enable again, the parameter "addService" did not work and did not geenrate any error. I tried some diferents sintaxes (comma, quotes, etc) but no luck. I saw the documentation too.

Can you help me with this, please?

----

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

2

Re: Disable and enable SMTP for an domain

What's the API code you used to post "addService"?

3 (edited by f.barboza 2024-08-24 02:13:25)

Re: Disable and enable SMTP for an domain

ZhangHuangbin wrote:

What's the API code you used to post "addService"?


I'm using pyhton. To remove (and works fine) I used:
resp = requests.put('%s/user/%s' % (URL_IRED, conta), cookies=cookies, data={'removeService':'smtp,smtpsecured'})



To add a smtp service that not working, I tried the two ways below:

resp = requests.put('%s/user/%s' % (URL_IRED, conta), cookies=cookies, data={'addService':'smtp,smtpsecured'})

resp = requests.put('%s/user/%s' % (URL_IRED, conta), cookies=cookies, data={'addService':'smtpsecured'})

4

Re: Disable and enable SMTP for an domain

Will try to reproduce this issue shortly, stay tuned.

5

Re: Disable and enable SMTP for an domain

Confirmed it's a bug and here's the patch to fix it. Thanks for the feedback. smile

diff --git a/libs/sqllib/user.py b/libs/sqllib/user.py
index c17d814c..4be57086 100644
--- a/libs/sqllib/user.py
+++ b/libs/sqllib/user.py
@@ -2574,7 +2574,7 @@ def api_update_profile(mail, form, conn=None):
     else:
         if 'addService' in form:
             _v = form_utils.get_multi_values_from_api(form=form, input_name='addService')
-            for i in _new:
+            for i in _v:
                 _srv = 'enable' + i
                 params[_srv] = 1
 

If you're not familiar with patch, please send me a message (zhb _at_ iredmail.org) to get patched version (i didn't find your forum email address in our license database).