Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com
huuphan.com. Powered by Blogger.

Explore the world of seamless email management with Zimbra Mail on Linux! Our blog delves into a step-by-step guide on harnessing the potential of Linux commands, providing easy-to-follow how-tos, and unlocking the magic of Bash scripting. Simplify your email administration journey and enhance your skills with our insightful tips and tricks.

zimbra create multiple accounts csv file

I will writing the script for create multiple accounts from csv file.
  1. To create Accounts.csv file
  2. To use bash script create multiple accounts in zimbra
  3. To execute zimbra_account.sh bash script
I'm created Accounts.csv file
# cat Accounts.csv 
The content Accounts.csv file as below:
[email protected],123456789,Huu1,Phan Van,Phan Van Huu1 (IT),mail.huuphan.local
[email protected],123456789,Huu2,Phan Van,Phan Van Huu2 (IT),mail.huuphan.local

zimbra create multiple accounts csv file full script

zimbra create multiple accounts with zimbra_account.sh name
#!/bin/bash
# File Accounts.csv as below:
# [email protected],123456789,Huu1,Phan Van,Phan Van Huu1 (IT),mail.huuphan.local
# [email protected],123456789,Huu2,Phan Van,Phan Van Huu2 (IT),mail.huuphan.local
DATE=$(date)
OLDIFS=$IFS
IFS=','
File_Name="/opt/Account/Accounts.csv"
Out_log='/tmp/outfile.log'
        echo "$DATE - To create account Email" | tee $Out_log
        echo "Account, Password, First_Name, Last_Name, DisplayName, zimbraMailHost" | tee -a $Out_log
while read Acount_Email Password First_Name Last_Name Display_Name Mailbox
do
        echo "$Acount_Email, $Password, $First_Name, $Last_Name, $Display_Name, $Mailbox" | tee -a $Out_log
        echo ""
Uid=$(echo $Acount_Email | cut -d '@' -f1)
Domain=$(echo $Acount_Email | cut -d '@' -f2)
su - zimbra -c "zmprov -l gaa | grep '\b$Uid'@$Domain"
if [ $? -eq 0 ] ; then
        echo "$Acount_Email exits"
else
        su - zimbra -c "zmprov ca '$Acount_Email' '$Password' givenName '$First_Name' sn '$Last_Name' displayName '$Display_Name' zimbraMailHost '$Mailbox'" >>$Out_log
fi

done < ${File_Name}
IFS=$OLDIFS
To execute bash script
#./zimbra_account.sh


post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com

3 Comments

ERROR: service.INVALID_REQUEST (invalid request: must be valid email address: account)

I am getting such an error can cause problems

Relay

I have same error. ERROR: service.INVALID_REQUEST (invalid request: must be valid email address: account)

Relay

Hello,

I can't solve problem below. Hostname is true. Can you help me ?

ERROR: service.INVALID_REQUEST (invalid request: specified zimbraMailHost does not correspond to a valid server service hostname: mail.xxx.xxx)

Relay

This Blog is protected by DMCA.com