Setup Mailcow Alias with MariaDB SQL or API

Modified on Thu, 10 Sep at 1:32 PM

sudo -i
cd /opt/mailcow-dockerized
docker exec -it $(docker ps -qf name=mysql-mailcow) mariadb -u mailcow -p$(grep 'DBPASS' mailcow.conf | cut -d'=' -f2)

USE mailcow;
INSERT INTO alias (address, goto, domain, created, modified, private_comment, public_comment, sogo_visible, internal, active, sender_allowed) VALUES ('alias@domain.com', 'mailcow@domain.com', 'domain.com', NOW(), NULL, NULL, NULL, 1, 0, 1, 1);


Need to reboot for them to show.



Alternatively, insert using the Mailcow API:

# Enable API in Mailcow UI: Configuration -> Access -> API
# Obtain your Read-Write API Key, then run:

curl -X POST "https://<MAILCOW_HOSTNAME>/api/v1/add/alias" \
  -H "X-API-Key: YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "address": "alias@domain.com",
    "goto": "mailcow@domain.com",
    "active": "1",
    "sogo_visible": "1"
  }'

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article