Links to below you maybe likes:
zimbra custom spamassassin rules
How to create auto Bcc for Recipient mails for Zimbra 8.6
How to add spam filters on zimbra 8.6
How to create auto Bcc for sender mails for Zimbra 8.6
list accounts that has not logged in for the last x days in zimbra
Method 1: To bash script use zimbra ldap check zimbra account status.
#!/bin/bash
# sed ':a;N;$!ba;s/\n/ /g' file : command line
# :a create a label 'a'
# N append the next line to the pattern space
# $! if not the last line, ba branch (go to) label 'a'
# s substitute, /\n/ regex for new line, / / by a space, /g global match (as many times as it can)
# sed will loop through step 1 to 3 until it reach the last line, getting all lines fit in the pattern space where sed will substitute all \n characters
LDAP_HOST=`/opt/zimbra/bin/zmlocalconfig ldap_host | cut -d\ '' -f3`
LDAP_PASSWORD=`/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_password | cut -d\ '' -f3`
LDAP_USERDN=`/opt/zimbra/bin/zmlocalconfig zimbra_ldap_userdn | cut -d\ '' -f3`
LDAPSEARCH="/opt/zimbra/bin/ldapsearch -D "$LDAP_USERDN" -w$LDAP_PASSWORD -H ldap://$LDAP_HOST -LLL -o ldif-wrap=no"
ZIMBRA_ACCOUNT_STATUS="zimbraAccountStatus"
DOMAIN=$1
$LDAPSEARCH "(&(objectClass=zimbraAccount)($ZIMBRA_ACCOUNT_STATUS=*)(mail=*$DOMAIN))" $ZIMBRA_ACCOUNT_STATUS | sed 's/ou=people,//g' | sed 's/dn: uid=/:/g' | sed 's/,dc=/@/' | sed 's/,dc=/./g' | sed 's/,dc=/./g' | sed ':a;N;$!ba;s/\n/ /g' | sed "s/$ZIMBRA_ACCOUNT_STATUS: //g" | sed 's/:/\n/g
Method 2: To use zmaccts command line check zimbra account status.
$ zmaccts | grep active | grep @mail.huuphan.local | awk '{print $1}'
Thanks for reading How to check zimbra account status My blog Effortless Zimbra Mail Management: Unleashing the Power of Linux Commands, How-To, and Bash Scripts I hope this is useful.
4 Comments
What if the most desired document or letter is lost or theft along with the letterbox? The result might be catastrophic sometime! So, it should be the foremost duty to ensure the safety of your documents outside the door. A secure and heavy duty locking mailbox can do this. We were in search of the best secure mailbox.
RelaySecond "sed 's/,dc=/./g'" in method #1 is unnecessary because the first one already replaced all ",dc=" with dots.
RelayAlso, you lost the closing apostrophe of mehod #1
Thank you
RelayAlso, first and last calls to sed could be combined into single command to avoid unnecessary invocations of sed:
Relay$LDAPSEARCH "(&(objectClass=zimbraAccount)(!($ZIMBRA_ACCOUNT_STATUS=active))(mail=*$DOMAIN))" $ZIMBRA_ACCOUNT_STATUS \
| sed 's/ou=people,//g;s/dn: uid=/:/g;s/,dc=/@/;s/,dc=/./g' \
| sed ':a;N;$!ba;s/\n/ /g' \
| sed "s/$ZIMBRA_ACCOUNT_STATUS: //g;s/:/\n/g"
Newlines are inserted for clarity. See: the sed allows to specify several expressions in one command, and these expressions must be separated by semicolons.
I'm in no way criticize your style. I just suggesting some kind of optimizations. That is the spirit of the open-source: learn from each other, teach each other.