Nice, it is working partly, but it seems like the script fetch the password column as a user name and generate this output when the first line of the input txt-file looks like this: ole.olsen It)mW7577
INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created)
VALUES ('ole.olsen@mydomain.com', '$1$ROn.Rtdf$cf9KF..EAeeCWCUO/mcKx0', ole.olsen', '/var','vmail', 'mydomain.com/f/o/l/e/ole.olsen-2014.05.20.08.42.23/', '100', $
INSERT INTO alias (address, goto, domain, created, active) VALUES ('ole.olsen@mydomain.com', 'ole.olsen@mydomain.com','mydomain.com', NOW(), 1);
INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created)
VALUES ('It)mW7577^M@mydomain.com', '$1$ROn.Rtdf$cf9KF..EAeeCWCUO/mcKx0', 'It)mW7577^M', '/var','vmail', 'mydomain.com/I/t/)/It)mW7577^M-2014.05.20.08.42.23/', '100', 'nesse$
INSERT INTO alias (address, goto, domain, created, active) VALUES ('It)mW7577^M@myadomain.com', 'It)mW7577^M@mydomain.com','mydomain.com', NOW(), 1);
INSERT INTO mailbox (username, password, name, storagebasedirectory,storagenode, maildir, quota, domain, active, local_part, created)
(I first changed the storage_base_directory to /var/vmail, but changed it back again afterwards)
ZhangHuangbin wrote:iRedMail ships a shell script for bulk adding mail users: iRedMail-0.8.7/tools/create_mail_user_SQL.sh.
If you have password as second field in each line of this text file, please update 'tools/create_mail_user_SQL.sh' with below steps:
1: Find below lines in 'tools/create_mail_user_SQL.sh':
DEFAULT_PASSWD='88888888'
USE_DEFAULT_PASSWD='NO'
echo '' > ${SQL}
2: Change them to:
DEFAULT_PASSWD="$3" # WARNING: Must use double quote ("), not single quote (').
USE_DEFAULT_PASSWD='YES'
echo '' >> ${SQL} # Two '>'
3: Remove '@domain.ltd' in your TXT file. For example:
- Original line: "user@mydomain.com Dj(pZ3054"
- After modified: "user Dj(pZ3054"
4: Execute this script with your txt file:
# cd iRedMail-0.8.7/tools/
# bash create_mail_user_SQL.sh YOUR_DOMAIN_NAME $(awk '{print $1,$2}' YOUR_TXT_FILE)
It will generate a new file 'output.sql' under current directory, please verify it first, if it's ok then import it into SQL server. NOTE: you need to create domain first manually.