需求: 将所有用户邮箱联系人中保存的旧域名联系人更新为新域名。
#!/bin/bash
for mailbox in `cat tt_staff_email.txt`? #全员邮箱
do
? ?ids=`/opt/zimbra/bin/zmmailbox -z -m $mailbox gact| grep -i id | awk -F ":" ‘{print $2}‘`? #获取所有联系人的id
? ?for i in ${ids[@]}
? ?do
? ? ? /opt/zimbra/bin/zmmailbox -z -m $mailbox gct $i | grep "olddomain.com"?
? ? ? if [[ $? -eq 0 ]];then
? ? ? ? ?contact=`/opt/zimbra/bin/zmmailbox -z -m $mailbox gct $i | grep "olddomain.com"|awk -F ":" ‘{print $2}‘|awk -F "@" ‘{print $1}‘`
? ? ? ? ?/opt/zimbra/bin/zmmailbox -z -m $mailbox mcta $i email "$contact"@newdomain.com
? ? ? fi
? ?done
? ?echo "$mailbox process done!" >> /home/shizhenning/process.log?
done
原文:https://blog.51cto.com/magic3/2826492