1

Topic: RESTFUL API addAlias cross domain

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

api : PUT /api/user/<mail>

Hello, seems the restful API to add mail alias is not following the setting USER_ALIAS_CROSS_ALL_DOMAINS = True

using the web admin we can add alias for mail account to different domain, but the API still dropping any different domain alias for user

----

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

2

Re: RESTFUL API addAlias cross domain

Could you please show me your full API request code to reproduce the issue? Hide sensitive info before pasting please.

3

Re: RESTFUL API addAlias cross domain

ZhangHuangbin wrote:

Could you please show me your full API request code to reproduce the issue? Hide sensitive info before pasting please.

# 1. Login

curl -k -c /tmp/cookie.txt -X POST https://127.0.0.1/iredadmin/api/login \
  --data-urlencode 'username=postmaster@example.local' \
  --data-urlencode 'password=******'; echo
  
{"_success": true}

# 2a. Create domain example.com

curl -k -b /tmp/cookie.txt -X POST https://127.0.0.1/iredadmin/api/domain/example.com \
  --data-urlencode 'name=example.com' \
  --data-urlencode 'quota=0'; echo
  
{"_success": true}

# 2b. Create domain example.net

curl -k -b /tmp/cookie.txt -X POST https://127.0.0.1/iredadmin/api/domain/example.net \
  --data-urlencode 'name=example.net' \
  --data-urlencode 'quota=0'; echo
  
{"_success": true}

# 3. Create user user@example.com

curl -k -b /tmp/cookie.txt -X POST https://127.0.0.1/iredadmin/api/user/user@example.com \
  --data-urlencode 'name=user' \
  --data-urlencode 'password=Test@12345678' \
  --data-urlencode 'quota=1024'; echo
  
{"_success": true}

# 4. Add cross-domain alias

curl -k -b /tmp/cookie.txt -X PUT https://127.0.0.1/iredadmin/api/user/user@example.com \
  --data-urlencode 'addAlias=cross@example.net'; echo
  
{"_success": true}

# 5. Get user details, show only username and aliases

curl -k -s -b /tmp/cookie.txt https://127.0.0.1/iredadmin/api/user/user@example.com | jq '{username: ._data.username, aliases: ._data.aliases}'; echo

{
  "username": "user@example.com",
  "aliases": []
}

# 6a. add alias for user@example.com from the iredadmin web manually

# 6b. Get user details, show only username and aliases, after adding manually from iredadmin

curl -k -s -b /tmp/cookie.txt https://127.0.0.1/iredadmin/api/user/user@example.com | jq '{username: ._data.username, aliases: ._data.aliases}'; echo

{
  "username": "user@example.com",
  "aliases": [
    "fromweb@example.net"
  ]
}