Serghey Rodin 14 лет назад
Родитель
Сommit
b825490946

+ 1 - 1
bin/v_add_mail_account_alias

@@ -2,7 +2,7 @@
 # info: add mail account alias aka nickname
 # options: user domain account alias
 #
-# The function add new email account.
+# The function add new email alias.
 
 
 #----------------------------------------------------------#

+ 2 - 2
bin/v_add_mail_account_autoreply

@@ -36,7 +36,7 @@ is_object_valid 'mail' 'DOMAIN' "$domain"
 is_object_unsuspended 'mail' 'DOMAIN' "$domain"
 is_object_valid "mail/$domain" 'ACCOUNT' "$account"
 is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
-is_object_value_empty "mail/$domain" 'ACCOUNT' "$domain" '$AUTOREPLY'
+# is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY'
 
 
 #----------------------------------------------------------#
@@ -55,7 +55,7 @@ chmod 660 $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg
 # Adding vesta alias
 echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg
 chmod 660 $USER_DATA/mail/$account@$domain.msg
-update_object_value "mail/$domain" 'ACCOUNT' "$domain" '$AUTOREPLY' 'yes'
+update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes'
 
 # Logging
 log_history "$EVENT"

+ 73 - 0
bin/v_add_mail_account_forward

@@ -0,0 +1,73 @@
+#!/bin/bash
+# info: add mail account forward address
+# options: user domain account forward
+#
+# The function add new email account.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+forward=$4
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'user domain account forward'
+validate_format 'user' 'domain' 'account' 'forward'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD')
+if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then
+    echo "Error: forward $forward exists"
+    log_event "$E_EXISTS $EVENT"
+    exit $E_EXISTS
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding forward to exim
+if [ -z "$fwd" ]; then
+    fwd="$forward"
+else
+    fwd="$fwd,$forward"
+fi
+
+sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases
+echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating config
+update_object_value "mail/$domain" 'ACCOUNT' "$account"  '$FWD' "$fwd"
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 65 - 0
bin/v_change_mail_account_password

@@ -0,0 +1,65 @@
+#!/bin/bash
+# info: change mail account password
+# options: user domain account password
+#
+# The function changes email account password.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+password=$4
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'user domain account password'
+validate_format 'user' 'domain' 'account' 'password'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+md5=$(/usr/sbin/dovecotpw -s md5 -p "$password")
+sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
+str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
+echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update md5
+update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5"
+
+# Hiding password
+EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
+EVENT="$EVENT ARGUMENTS='$user $domain *****'"
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 62 - 0
bin/v_change_mail_account_quota

@@ -0,0 +1,62 @@
+#!/bin/bash
+# info: change mail account quota
+# options: user domain account quota
+#
+# The function changes email account disk quota.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+quota=$4
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'user domain account quota'
+validate_format 'user' 'domain' 'account' 'quota'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
+sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
+str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
+echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update quota
+update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 65 - 0
bin/v_delete_mail_account

@@ -0,0 +1,65 @@
+#!/bin/bash
+# info: delete mail account
+# options: user domain account
+#
+# The function deletes email account.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'user domain account'
+validate_format 'user' 'domain' 'account'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS')
+for al in ${aliases//,/ }; do
+    sed -i "/^$al@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases
+done
+
+sed -i "/^$account@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
+sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
+rm -rf $HOMEDIR/$user/mail/$domain/$account
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update config
+sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf
+
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 70 - 0
bin/v_delete_mail_account_alias

@@ -0,0 +1,70 @@
+#!/bin/bash
+# info: delete mail account alias aka nickname
+# options: user domain account alias
+#
+# The function deletes email account alias.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+malias=$4
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'user domain account alias'
+validate_format 'user' 'domain' 'account' 'malias'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS')
+if [ -z "$(echo $aliases | grep -w $malias)" ]; then
+    echo "Error: alias $malias is not exist"
+    log_event "$E_NOTEXIST $EVENT"
+    exit $E_NOTEXIST
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+sed -i "/^$malias@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases
+aliases=$(echo "$aliases" |\
+    sed -e "s/,/\n/g"|\
+    sed -e "s/^$malias$//g"|\
+    sed -e "/^$/d"|\
+    sed -e ':a;N;$!ba;s/\n/,/g')
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update config
+update_object_value "mail/$domain" 'ACCOUNT' "$account"  '$ALIAS' "$aliases"
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 61 - 0
bin/v_delete_mail_account_autoreply

@@ -0,0 +1,61 @@
+#!/bin/bash
+# info: delete mail account autoreply message
+# options: user domain account alias
+#
+# The function delete email account autoreply.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+malias=$4
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'user domain account'
+validate_format 'user' 'domain' 'account'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg
+rm -f $USER_DATA/mail/$domain/$account@$domain.msg
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update config
+update_object_value "mail/$domain" 'ACCOUNT' "$account"  '$AUTOREPLY' 'no'
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 72 - 0
bin/v_delete_mail_account_forward

@@ -0,0 +1,72 @@
+#!/bin/bash
+# info: delte mail account forward
+# options: user domain account email
+#
+# The function add delete email account forward address.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+forward=$4
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'user domain account forward'
+validate_format 'user' 'domain' 'account' 'forward'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD')
+if [ -z "$(echo $fwd | grep -w $forward)" ]; then
+    echo "Error: forward $forward is not exist"
+    log_event "$E_NOTEXIST $EVENT"
+    exit $E_NOTEXIST
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+fwd=$(echo "$fwd" |\
+    sed -e "s/,/\n/g"|\
+    sed -e "s/^$forward$//g"|\
+    sed -e "/^$/d"|\
+    sed -e ':a;N;$!ba;s/\n/,/g')
+
+sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases
+echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update config
+update_object_value "mail/$domain" 'ACCOUNT' "$account"  '$FWD' "$fwd"
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 94 - 0
bin/v_list_mail_account

@@ -0,0 +1,94 @@
+#!/bin/bash
+# info: list mail domain account
+# options: user domain account [format]
+#
+# The function of obtaining the list of account parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$2
+account=$3
+format=${4-shell}
+
+# Includes
+source $VESTA/func/shared.sh
+
+# Json function
+json_list_account() {
+    i=1
+    fileds_count=$(echo "$fields" | wc -w)
+    line=$(grep "ACCOUNT='$account'" $conf)
+    echo '{'
+    eval $line
+    for field in $fields; do
+        eval value=$field
+        if [ "$i" -eq 1 ]; then
+            echo -e "\t\"$value\": {"
+        else
+            if [ "$fileds_count" -eq "$i" ]; then
+                echo -e "\t\t\"${field//$/}\": \"$value\","
+            else
+                echo -e "\t\t\"${field//$/}\": \"$value\""
+            fi
+        fi
+        (( ++i))
+    done
+    if [ -n "$value" ]; then
+        echo -e '        }'
+    fi
+    echo -e "}"
+}
+
+# Shell function
+shell_list_account() {
+    line=$(grep "ACCOUNT='$account'" $conf)
+    eval $line
+    for field in $fields; do
+        eval key="$field"
+        if [ -z "$key" ]; then
+            key=NULL
+        fi
+        echo "${field//$/}: $key "
+    done
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'user domain account [format]'
+is_object_valid 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config and fields to select
+conf=$USER_DATA/mail/$domain.conf
+fields="\$ACCOUNT \$ALIAS \$FWD \$QUOTA \$AUTOREPLY \$U_DISK \$SUSPENDED"
+fields="$fields \$TIME \$DATE"
+
+# Listing domains
+case $format in 
+    json)   json_list_account ;;
+    plain)  nohead=1; shell_list_account ;;
+    shell)  shell_list_account |column -t ;;
+    *)      check_args '2' '0' 'user domain account [format]'
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 72 - 0
bin/v_list_mail_account_autoreply

@@ -0,0 +1,72 @@
+#!/bin/bash
+# info: list mail account autoreply
+# options: user domain account [format]
+#
+# The function of obtainin mail account autoreply message.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$2
+account=$3
+format=${4-shell}
+
+# Includes
+source $VESTA/func/shared.sh
+
+# Json function
+json_list_msg() {
+    i='1'       # iterator
+    echo '{'
+    echo -e "\t\"$account\": {"
+    echo "        \"MSG\": \"$msg\""
+    echo -e "\t}\n}"
+}
+
+# Shell function
+shell_list_msg() {
+    if [ ! -z "$msg" ]; then
+        echo -e "$msg"
+    fi
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'user domain [format]'
+is_object_valid 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+if [ -e "$USER_DATA/mail/$account@$domain.msg" ]; then
+    msg=$(cat $USER_DATA/mail/$account@$domain.msg |\
+        sed -e ':a;N;$!ba;s/\n/\\n/g' )
+fi
+
+# Listing domains
+case $format in
+    json)   json_list_msg ;;
+    plain)  nohead=1; shell_list_msg ;;
+    shell)  shell_list_msg ;;
+    *)      check_args '1' '0' '[format]'
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 3 - 2
bin/v_list_mail_accounts

@@ -34,13 +34,14 @@ is_object_valid 'mail' 'DOMAIN' "$domain"
 
 # Defining fileds to select
 conf=$USER_DATA/mail/$domain.conf
-fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$U_DISK \$SUSPENDED \$DATE"
+fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$QUOTA \$U_DISK \$SUSPENDED"
+fields="$fields \$TIME \$DATE"
 
 # Listing domain accounts
 case $format in 
     json)  json_list ;;
     plain) nohead=1; shell_list ;;
-    shell) fields='$ACCOUNT $ALIAS $FWD $AUTOREPLY $U_DISK $DATE';
+    shell) fields='$ACCOUNT $AUTOREPLY $QUOTA $U_DISK $SUSPENDED $TIME $DATE';
            shell_list | column -t ;;
     *)     check_args '1' '0' 'user [format]'
 esac

+ 8 - 1
bin/v_list_users

@@ -56,7 +56,14 @@ shell_list_users() {
 
     for USER in $(ls $VESTA/data/users/); do
         source $VESTA/data/users/$USER/user.conf
-        eval echo "$fields"
+        for field in $fields; do
+            eval value=$field
+            if [ -z "$value" ]; then
+                value='NULL'
+            fi
+            echo -n "$value "
+        done
+        echo
     done
 }
 

+ 48 - 12
bin/v_rebuild_mail_domains

@@ -46,13 +46,14 @@ if [ ! -d "$USER_DATA/mail" ]; then
 fi
 
 # Starting loop
-for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
-
+for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do
     # Defining variables
     get_domain_values 'mail'
 
     # Rebuilding config structure
+    rm -f /etc/exim/domains/$domain
     mkdir -p $HOMEDIR/$user/conf/mail/$domain
+    ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/
     rm -f $HOMEDIR/$user/conf/mail/$domain/aliases
     rm -f $HOMEDIR/$user/conf/mail/$domain/protection
     rm -f $HOMEDIR/$user/conf/mail/$domain/passwd
@@ -60,8 +61,10 @@ for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
     touch $HOMEDIR/$user/conf/mail/$domain/protection
     touch $HOMEDIR/$user/conf/mail/$domain/passwd
     chown -R root:mail $HOMEDIR/$user/conf/mail/$domain
+    chown -R root:mail /etc/exim/domains/$domain
     chmod 770 $HOMEDIR/$user/conf/mail/$domain
     chmod 660 $HOMEDIR/$user/conf/mail/$domain*
+    chmod 660 /etc/exim/domains/$domain
 
     # Adding antispam protection
     if [ "$ANTISPAM" = 'yes' ]; then
@@ -106,9 +109,10 @@ for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
         fi
     fi
 
-    # Adding antispam protection
-    if [ "$SUSPENDED" != 'yes' ]; then
-        ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/
+    # Removing symbolic link
+    if [ "$SUSPENDED" = 'yes' ]; then
+        SUSPENDED_MAIL=$((SUSPENDED_MAIL +1))
+        rm -f /etc/exim/domains/$domain
     fi
 
     if [ ! -e $HOMEDIR/$user/mail/$domain ]; then
@@ -117,9 +121,45 @@ for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
     chown $user:mail $HOMEDIR/$user/mail/$domain
     chmod 770 $HOMEDIR/$user/mail/$domain
 
-    # Rebuild counters
+    dom_aliases=$HOMEDIR/$user/conf/mail/$domain/aliases
+    if [ ! -z "$CATCHALL" ]; then
+        echo "*@$domain:$CATCHALL" >> $dom_aliases
+    fi
+
+    # Rebuild domain accounts
+    accs=0
+    dom_diks=0
+    if [ -e "$USER_DATA/mail/$domain.conf" ]; then
+        accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT')
+    else
+        accounts=''
+    fi
+
+    for account in $accounts; do
+        (( ++accs))
+        dom_diks=$((dom_diks + U_DISK))
+        object=$(grep "ACCOUNT='$account'" $USER_DATA/mail/$domain.conf)
+        eval "$object"
+        if [ "$SUSPENDED" = 'yes' ]; then
+            MD5='SUSPENDED'
+        fi
+
+        str="$account:$MD5:$user:mail::$HOMEDIR/$user:$QUOTA"
+        echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
+
+        for malias in ${ALIAS//,/ }; do
+            echo "$malias@$domain:$account@$domain" >> $dom_aliases
+        done
+        if [ ! -z "$FWD" ]; then
+            echo "$account@$domain:$FWD" >> $dom_aliases
+        fi
+
+    done
+    update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accs"
+    update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks"
+    U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accs))
+    U_DISK_MAIL=$((U_DISK_MAIL + dom_diks))
     U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1))
-    U_DISK_MAIL=$((U_DISK_MAIL + U_DISK))
 done
 
 
@@ -128,15 +168,11 @@ done
 #----------------------------------------------------------#
 
 # Updating counters
-U_MAIL_DOMAINS='0'
-U_MAIL_ACCOUNTS='0'
-SUSPENDED_MAIL='0'
-U_DISK_MAIL='0'
-
 update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS"
 update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS"
 update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL"
 update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL"
+recalc_user_disk_usage
 
 # Logging
 log_event "$OK" "$EVENT"

+ 37 - 0
bin/v_restart_mail

@@ -0,0 +1,37 @@
+#!/bin/bash
+# info: restart mail service
+# options: none
+#
+# The function tells Exim service to reload configuration files.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+EVENT=${1-$EVENT}
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+if [ "$MAIL_SYSTEM" = 'exim' ]; then
+    /etc/init.d/exim reload &>/dev/null
+    if [ $? -ne 0 ]; then
+        /etc/init.d/exim restart &>/dev/null
+        if [ $? -ne 0 ]; then
+            log_event "$E_RESTART" "$EVENT"
+            exit $E_RESTART
+        fi
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 61 - 0
bin/v_suspend_mail_account

@@ -0,0 +1,61 @@
+#!/bin/bash
+# info: suspend mail account
+# options: user domain account
+#
+# The function suspends mail account.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'user domain account'
+validate_format 'user' 'domain' 'account'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA')
+sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
+str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota"
+echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update config
+update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes'
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 54 - 0
bin/v_suspend_mail_accounts

@@ -0,0 +1,54 @@
+#!/bin/bash
+# info: suspend all mail domain accounts
+# options: user domain
+#
+# The function suspends all mail domain accounts.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'user domain'
+validate_format 'user' 'domain'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Starting suspend loop
+for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do
+    $BIN/v_suspend_mail_account "$user" "$domain" "$account"
+done
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 62 - 0
bin/v_unsuspend_mail_account

@@ -0,0 +1,62 @@
+#!/bin/bash
+# info: unsuspend mail account
+# options: user domain account
+#
+# The function unsuspends mail account.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+account=$3
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+source $VESTA/func/domain.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'user domain account'
+validate_format 'user' 'domain' 'account'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+is_object_valid "mail/$domain" 'ACCOUNT' "$account"
+is_object_suspended "mail/$domain" 'ACCOUNT' "$account"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
+quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA')
+sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
+str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
+echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Update config
+update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'no'
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 54 - 0
bin/v_unsuspend_mail_accounts

@@ -0,0 +1,54 @@
+#!/bin/bash
+# info: unsuspend all mail domain accounts
+# options: user domain
+#
+# The function unsuspends all mail domain accounts.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'user domain'
+validate_format 'user' 'domain'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Starting unsuspend loop
+for account in $(search_objects "mail/$domain" 'SUSPENDED' 'yes' 'ACCOUNT'); do
+    $BIN/v_unsuspend_mail_account "$user" "$domain" "$account"
+done
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 1 - 1
bin/v_unsuspend_mail_domains

@@ -12,7 +12,7 @@
 # Argument defenition
 user=$1
 
-# Importing variables
+# Includes
 source $VESTA/conf/vesta.conf
 source $VESTA/func/shared.sh
 source $VESTA/func/domain.sh

+ 65 - 0
bin/v_update_mail_domain_disk

@@ -0,0 +1,65 @@
+#!/bin/bash
+# info: update mail domain disk usage
+# options: user domain
+#
+# The function updates domain disk usage.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
+domain_idn=$(idn -t --quiet -a "$domain")
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'user domain'
+validate_format 'user' 'domain'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'mail' 'DOMAIN' "$domain"
+is_object_unsuspended 'mail' 'DOMAIN' "$domain"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Starting loop
+dom_diks=0
+for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do
+    home_dir=$HOMEDIR/$user/mail/$domain/$account
+    if [ -e "$home_dir" ]; then
+        udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 )
+    else
+        udisk=0
+    fi
+    update_object_value "mail/$domain" 'ACCOUNT' "$account"  '$U_DISK' "$udisk"
+    dom_diks=$((dom_diks + udisk))
+done
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks"
+recalc_user_disk_usage
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 64 - 0
bin/v_update_mail_domains_disk

@@ -0,0 +1,64 @@
+#!/bin/bash
+# info: calculate disk usage for all mail domains
+# options: user
+#
+# The function calculates disk usage for all mail domains.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+
+# Includes
+source $VESTA/conf/vesta.conf
+source $VESTA/func/shared.sh
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'user'
+validate_format 'user'
+is_system_enabled "$MAIL_SYSTEM"
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Starting loop
+for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do
+    dom_diks=0
+    accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT')
+    for account in $accounts; do
+        home_dir=$HOMEDIR/$user/mail/$domain/$account
+        if [ -e "$home_dir" ]; then
+            udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 )
+        else
+            udisk=0
+        fi
+        update_object_value "mail/$domain" 'ACCOUNT' "$account"  '$U_DISK' "$udisk"
+        dom_diks=$((dom_diks + udisk))
+    done
+    update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks"
+done
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+
+recalc_user_disk_usage
+
+# Logging
+log_history "$EVENT"
+log_event "$OK" "$EVENT"
+
+exit

+ 0 - 7
func/domain.sh

@@ -71,13 +71,6 @@ is_mail_new() {
         log_event "$E_EXISTS" "$EVENT"
         exit
     fi
-    check_fwd=$(awk -F "FWD='" '{print $2}' $USER_DATA/mail/$domain.conf )
-    check_fwd=$(echo "$check_fwd" | cut -f 1 -d "'" | grep -w $1)
-    if [ ! -z "$check_fwd" ]; then
-        echo "Error: mail forward $1 exist"
-        log_event "$E_EXISTS" "$EVENT"
-        exit
-    fi
 }
 
 # Update domain zone

+ 65 - 24
func/shared.sh

@@ -221,8 +221,7 @@ is_object_value_exist() {
 get_object_value() {
     object=$(grep "$2='$3'" $USER_DATA/$1.conf)
     eval "$object"
-    eval object_val="$4"
-    echo "$object_val"
+    eval echo $4
 }
 
 # Update object value
@@ -257,9 +256,11 @@ get_user_value() {
 # Update user value in user.conf
 update_user_value() {
     key="${2//$}"
-    conf="$VESTA/data/users/$1/user.conf"
-    old=$(grep "$key=" $conf | cut -f 2 -d \')
-    sed -i "s/$key='$old'/$key='$3'/g" $conf
+    lnr=$(grep -n "^$key='" $VESTA/data/users/$1/user.conf |cut -f 1 -d ':')
+    if [ ! -z "$lnr" ]; then
+        sed -i "$lnr d" $VESTA/data/users/$1/user.conf
+        sed -i "$lnr i\\$key='${3}'" $VESTA/data/users/$1/user.conf
+    fi
 }
 
 # Increase user counter
@@ -349,18 +350,46 @@ shell_list() {
 
 # Recalculate U_DISK value
 recalc_user_disk_usage() {
+    u_usage=0
+    if [ -f "$USER_DATA/web.conf" ]; then
+        usage=0
+        dusage=$(grep 'U_DISK=' $USER_DATA/web.conf |\
+            awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
+        for disk_usage in $dusage; do 
+                usage=$((usage + disk_usage))
+        done
+        d=$(grep "U_DISK_WEB='" $USER_DATA/user.conf | cut -f 2 -d \')
+        sed -i "s/U_DISK_WEB='$d'/U_DISK_WEB='$usage'/g" $USER_DATA/user.conf
+        u_usage=$((u_usage + usage))
+    fi
+
+    if [ -f "$USER_DATA/mail.conf" ]; then
+        usage=0
+        dusage=$(grep 'U_DISK=' $USER_DATA/mail.conf |\
+            awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
+        for disk_usage in $dusage; do 
+                usage=$((usage + disk_usage))
+        done
+        d=$(grep "U_DISK_MAIL='" $USER_DATA/user.conf | cut -f 2 -d \')
+        sed -i "s/U_DISK_MAIL='$d'/U_DISK_MAIL='$usage'/g" $USER_DATA/user.conf
+        u_usage=$((u_usage + usage))
+    fi
+
+    if [ -f "$USER_DATA/db.conf" ]; then
+        usage=0
+        dusage=$(grep 'U_DISK=' $USER_DATA/db.conf |\
+            awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
+        for disk_usage in $dusage; do 
+                usage=$((usage + disk_usage))
+        done
+        d=$(grep "U_DISK_DB='" $USER_DATA/user.conf | cut -f 2 -d \')
+        sed -i "s/U_DISK_DB='$d'/U_DISK_DB='$usage'/g" $USER_DATA/user.conf
+        u_usage=$((u_usage + usage))
+    fi
     usage=$(grep 'U_DIR_DISK=' $USER_DATA/user.conf | cut -f 2 -d "'")
-    for conf_type in mail db web; do
-        if [ -f "$USER_DATA/$conf_type.conf" ]; then
-            dusage=$(grep 'U_DISK=' $USER_DATA/$conf_type.conf |\
-                awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \')
-            for disk in $dusage; do 
-                usage=$((usage + disk))
-            done
-        fi
-    done
+    u_usage=$((u_usage + usage))
     old=$(grep "U_DISK='" $USER_DATA/user.conf | cut -f 2 -d \')
-    sed -i "s/U_DISK='$old'/U_DISK='$usage'/g" $USER_DATA/user.conf
+    sed -i "s/U_DISK='$old'/U_DISK='$u_usage'/g" $USER_DATA/user.conf
 }
 
 # Recalculate U_BANDWIDTH value
@@ -449,8 +478,8 @@ validate_format_int() {
 
 # Boolean
 validate_format_boolean() {
-    if [ "$1" != 'yes' ] ||  [ "$1" != 'no' ]; then
-        echo "Error: boolean $1 is not valid"
+    if [ "$1" != 'yes' ] && [ "$1" != 'no' ]; then
+        echo "Error: $2 $1 is not valid"
         log_event "$E_INVALID" "$EVENT"
         exit $E_INVALID
     fi
@@ -517,7 +546,7 @@ validate_format_username() {
 
 # Domain
 validate_format_domain() {
-    exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%| ]"
+    exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]"
     dpart1=$(echo $1 | cut -f 1 -d .)
     if [[ "$1" =~ $exclude ]] || [ -z "$dpart1" ]; then
         echo "Error: domain $1 is not valid"
@@ -528,7 +557,7 @@ validate_format_domain() {
 
 # Database
 validate_format_database() {
-    exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%| ]"
+    exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%|\`| ]"
     if [[ "$1" =~ $exclude ]] || [ 17 -le ${#1} ]; then
         echo "Error: database $1 is not valid"
         log_event "$E_INVALID" "$EVENT"
@@ -589,7 +618,7 @@ validate_format_mhdmw() {
 
 # Nginx static extention or DNS record
 validate_format_common() {
-    exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%| ]"
+    exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%|\`| ]"
     if [[ "$1" =~ $exclude ]] || [ 200 -le ${#1} ]; then
         echo "Error: $2 $1 is not valid"
         log_event "$E_INVALID" "$EVENT"
@@ -627,6 +656,16 @@ validate_format_date() {
     fi
 }
 
+# Autoreply
+validate_format_autoreply() {
+    exclude="[$|\`]"
+    if [[ "$1" =~ $exclude ]] || [ 10240 -le ${#1} ]; then
+        echo "Error: autoreply is not valid"
+        log_event "$E_INVALID" "$EVENT"
+        exit $E_INVALID
+    fi
+}
+
 # Format validation controller
 validate_format(){
     for arg_name in $*; do
@@ -639,8 +678,9 @@ validate_format(){
 
         case $arg_name in
             account)        validate_format_username "$arg" "$arg_name" ;;
-            antispam)       validate_format_boolean "$arg" ;;
-            antivirus)      validate_format_boolean "$arg" ;;
+            antispam)       validate_format_boolean "$arg" 'antispam' ;;
+            antivirus)      validate_format_boolean "$arg" 'antivirus' ;;
+            autoreply)      validate_format_autoreply "$arg" ;;
             backup)         validate_format_date "$arg" ;;
             charset)        validate_format_username "$arg" "$arg_name" ;;
             charsets)       validate_format_common "$arg" 'charsets' ;;
@@ -648,7 +688,7 @@ validate_format(){
             day)            validate_format_mhdmw "$arg" $arg_name ;;
             dbpass)         validate_format_password "$arg" ;;
             dbuser)         validate_format_database "$arg" ;;
-            dkim)           validate_format_boolean "$arg" ;;
+            dkim)           validate_format_boolean "$arg" 'dkim' ;;
             dkim_size)      validate_format_key_size "$arg" ;;
             domain)         validate_format_domain "$arg" ;;
             dom_alias)      validate_format_domain "$arg" ;;
@@ -657,6 +697,7 @@ validate_format(){
             exp)            validate_format_date "$arg" ;;
             extentions)     validate_format_common "$arg" 'extentions' ;;
             fname)          validate_format_username "$arg" "$arg_name" ;;
+            forward)        validate_format_email "$arg" ;;
             host)           validate_format_domain "$arg" "$arg_name" ;;
             hour)           validate_format_mhdmw "$arg" $arg_name ;;
             id)             validate_format_int "$arg" ;;
@@ -684,7 +725,7 @@ validate_format(){
             password)       validate_format_password "$arg" ;;
             port)           validate_format_int "$arg" ;;
             quota)          validate_format_int "$arg" ;;
-            restart)        validate_format_boolean "$arg" ;;
+            restart)        validate_format_boolean "$arg" 'restart' ;;
             record)         validate_format_common "$arg" 'record';;
             rtype)          validate_format_dns_type "$arg" ;;
             shell)          validate_format_shell "$arg" ;;