1

Looking at the vmail database of the iRedMail installation I see an alias_domain table which is currently empty.

Is it possible to add domain aliases with a MySQL query directly on the vmail.alias_domain table?

MechaNikos
  • 11
  • 1
  • 2

2 Answers2

1

To use my Canadian .ca site as an alias to my .com site I would use something like.

mysql -uroot -p
mysql> USE vmail;
mysql> INSERT INTO alias_domain (alias_domain, target_domain) values ('mysite.ca', 'mysite.com');

user201466
  • 11
  • 1
  • Did not work for me, any idea why? Mails are rejected with: ` Recipient address rejected: User unknown in virtual mailbox table.` – Amir Ali Akbari May 21 '14 at 14:20
  • Field **active** needs to set to 1 as well. INSERT INTO alias_domain (alias_domain, target_domain, active) VALUES ('mysite.ca', 'mysite.com', 1); – jpforte-user227739 Jun 24 '14 at 16:50
0

I created a script to do the dirty work.

Cut and paste below into a file add_domain.sh, then chmod 755 the file and run it with ./add_domain.sh alias_domain target_existing_domain OR ./add_domain.sh list to list the existing domains.


#!/bin/bash
# 2014 Aug 16 James Forte, Magna Computer Corp

if [ "$1" == "list" ]
then
    mysql vmail -e 'select * from alias_domain'
    exit 0
fi

if [ $# -lt 2 ]
then
    echo usage "$0: alias_domain target_existing_domain"
    exit 1
fi

CREATED=`date  +%Y-%m-%d`

echo -e "\nScript assumes that .my.cnf has passwords in it\n"
echo "Adding alias domain $1 to existing domain $2"

mysql vmail -e "INSERT INTO alias_domain (alias_domain, target_domain, created, active) 
                VALUES ('$1','$2','$CREATED',1);"
exit 0