#!/bin/sh #This script will make a list of all Zimbra accounts excluding system account #and use that list to upload an HTML signature and associated PNG image file #to each account in the list. It will write each account name to a list in a file #as the signature/png is uploaded. The next time this script is run it will upload #the signature/png only to accounts that aren't already in the file list. To upload #a new signature (such as a new revision/etc) to all accounts again, simply delete #the file containing the list of account names. #Be sure to make the /opt/zimbra/automation folder and chown it zimbra:zimbra #To prepare a signature, create it first and test it out in Zimbra. Once satisfied #attach image file using a permanent name (like company_logo.png). Copy the source #HTML from the Zimbra signature and paste it into the html_sig_file. Open the html_sig_file #and find the line similar to "home/user@domain.com/Briefcase/E-Mail_Logo_A.png" and change # "user@domain.com" to "userAccountEmailAddress" witout quotes ofc. #List containing accounts with signatures already uploaded acct_with_sig_file='/opt/zimbra/automation/signature_accounts_list.txt' #The HTML signature code in a file html_sig_file='/opt/zimbra/automation/Courtesy_E-Mail_Signature_05-21-19.txt' #The PNG graphics file used in HTML signature image_01_file='/opt/zimbra/automation/Courtesy_E-Mail_Logo_A.png' #Name of Signature Template as shown in Zimbra signature_name='Courtesy Signature Template 05-21-19a' #Name of uploaded image file as shown in Zimbra Briefcase; note this needs to be the same as the image file name referenced in the HTML signature file image_01_name='Courtesy_E-Mail_Logo_A.png' #create list of all Zimbra accounts; exclude system accounts all_accounts=`zmprov -l gaa | grep -v "^\(admin@\|wiki@\|spam.*@\|ham.*@\|virus.*@\|galsync@\|galsync.*@\|virus-*@\)"` #check if a list of accounts with signatures exists; if not then create an empty file if [ ! -e "$acct_with_sig_file" ] ; then touch "$acct_with_sig_file" fi #for each account found, check if that account exists in the "accounts with signatures" file, #if it doesn't exist then add the account name to the file and upload an image file and html signature for account in $all_accounts; do grep -q -F "$account" "$acct_with_sig_file"; if [ $? -ne 0 ]; then echo "$account" >> "$acct_with_sig_file"; zmmailbox -z -m $account postRestURL --contentType image/png /Briefcase/"$image_01_name" "$image_01_file"; html_sig_output=$(sed "s/userAccountEmailAddress/${account}/g" "$html_sig_file"); zmprov csig $account "$signature_name" zimbraPrefMailSignatureHTML "$html_sig_output"; fi done ;