Hi, All!
There is script that can add user with not-predifined password
#!/bin/bash
# Usage:
# program_name mysql_root_passwd mail_user_name mail_user_passwd
if [ $# -lt 4 ]; then
echo "Usage: $0 mysql_root_passwd mail_user_name mail_user_passwd mysql_user_domain"
exit;
fi
DEFAULT_PASSWD=$3
username=$2
DOMAIN=$4
# Default mail quota.
DEFAULT_QUOTA='100' # 100 -> 100M
# Cyrpt the password.
export CRYPT_PASSWD="$(openssl passwd -1 ${DEFAULT_PASSWD})"
maildir="${DOMAIN}/${username}"
#sqltext="use vmail;INSERT INTO mailbox (username, password, name, maildir, quota, domain, active) VALUES (\'${username}@${DOMAIN}\', \'${CRYPT_PASSWD}\', \'${username}\', \'${maildir}\', \'${DEFAULT_QUOTA}\', \'${DOMAIN}\', \'1\');"
sqltext="use vmail;INSERT INTO mailbox (username, password, name, maildir, quota, domain, active) VALUES ('${username}@${DOMAIN}', '${CRYPT_PASSWD}', '${username}', '${maildir}', '${DEFAULT_QUOTA}', '${DOMAIN}', '1');"
#sqltext="use vmail;SELECT * FROM `mailbox`;"
echo $sqltext;
/usr/bin/mysql -uroot -p$1 -h localhost -e "$sqltext"