add check for email address with name of alias
This commit is contained in:
parent
c874358e2d
commit
fedf6f036b
@ -57,9 +57,16 @@ elif [[ $mbox_id -gt 0 ]]; then
|
|||||||
# verified mbox, check for existing alias
|
# verified mbox, check for existing alias
|
||||||
existing_alias=`mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -s -r -N -e "SELECT vm_aliases.id FROM vm_aliases WHERE vm_aliases.alias='$alias' AND vm_aliases.mbox_id='$mbox_id';"`
|
existing_alias=`mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -s -r -N -e "SELECT vm_aliases.id FROM vm_aliases WHERE vm_aliases.alias='$alias' AND vm_aliases.mbox_id='$mbox_id';"`
|
||||||
if [[ -z $existing_alias ]]; then
|
if [[ -z $existing_alias ]]; then
|
||||||
# existing alias does not exist, add new one now
|
# existing alias does not exist, make sure mbox with alias name does not exist
|
||||||
dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -e 'INSERT INTO vm_aliases SET vm_aliases.alias=\"$alias\", vm_aliases.mbox_id=\"$mbox_id\";'"
|
alias_mbox_id=`mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -s -r -N -e "SELECT id FROM vm_mboxes WHERE domain_id='$domain_id' AND mbox='$alias';"`
|
||||||
eval $dbcmd
|
if [[ -z $alias_mbox_id ]]; then
|
||||||
|
# mailbox does not exist, add alias
|
||||||
|
dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -e 'INSERT INTO vm_aliases SET vm_aliases.alias=\"$alias\", vm_aliases.mbox_id=\"$mbox_id\";'"
|
||||||
|
eval $dbcmd
|
||||||
|
else
|
||||||
|
echo "ERROR: Email account $alias@$domain exists, can't create alias with the same name."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: Alias for $alias To $email already exists."
|
echo "ERROR: Alias for $alias To $email already exists."
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user