King0770-Notes: Difference between revisions

Line 33: Line 33:<br><br><br><br><br>

==Removing Messages with Zmmailbox based on the Subject==
==Removing Messages with Zmmailbox based on the Subject==

Revision as of 21:48, 28 November 2017

Additional Articles by King0770

Removing Messages with Zmmailbox based on the Subject

# subject
if [ -z "$2" ]; then
echo "usage: <subject>"
exit 0
echo "Searching $addr  for Subject:  $subject"
for msg in `zmmailbox -z -m "$addr" s -l 999 -t message "subject:$subject"|awk '{ if (NR!=1) {print}}' | grep -v -e Id -e "-" -e "^$" | awk '{ print $2 }'`
echo "Removing "$msg""
zmmailbox -z -m $1 dm $msg

Copy/Paste the script into a file, call it what you want, something like, "". The syntax using the script would be something like:

./ subjectName

If the subject contains more than one word, put double quotes around the subject.

./ "Hello World"

Special thanks to Matt Fox.

Logger Issues - Reinitialize the Logger DB

Worst case scenario for the logger db's: If some for reason the USE_FRM option fails, you could move the old logger db out of the way and start over. The only bad part is that you would lose historical data, however it would resolve the corrupted table issue(s).

If you wish the start over with the logger db's, here are the steps (run as zimbra).

$ zmloggerctl stop
$ mv /opt/zimbra/logger/db /opt/zimbra/logger/db-old
$ source /opt/zimbra/bin/zmshutil 
$ zmsetvars 
$ /opt/zimbra/libexec/zmloggerinit ${mysql_logger_root_password}
$ zmlogswatchctl start

Logger Issues - Improve Disk Utilization for the logger service

a) Keep less log on disk by editing the zimbraLogRawLifetime and the zimbraLogSymmaryLifetime attributes and run zmlogprocess utility. The default values for those two attributes are:
zimbraLogRawLifetime: 31d
zimbraLogSummaryLifetime: 730d

You can be set these two attributes aggressively if you opted to. Below is an example:

su - zimbra
zmprov mcf zimbraLogRawLifetime 14d
zmprov mcf zimbraLogSummaryLifetime 30d

The zmlogprocess script does optimize the logger database tables as it runs.

Notable bug report:

License - Misc

TTL for the account count cache is either 1 minute when they are very close to the limit, or 1 hour if the total account count is less than 90% of the quota. In other words, the server will correct itself without restart in an hour in the worse case. See

  • Admin counts towards user count,
  • Spam, Ham, Wiki accounts don't count toward user count total

Handy Commands

Read the install history file in a readable format

perl -e 'while (<>) { ($date, $op) = split(/:/, $_); print scalar localtime($date) . "  " . $op; }' < /opt/zimbra/.install_history


perl -an -F: -e 'print scalar localtime(shift @F), " @F";' /opt/zimbra/.install_history

Get the version in ZWC

Type the following in the search bar:

$set: get version

LDAP - DB Status

/opt/zimbra/sleepycat/bin/db_stat -c -h /opt/zimbra/openldap-data

LDAP - DB Recover

/opt/zimbra/sleepycat/bin/db_recover **make sure you are doing this as the zimbra user, and that slapd is not running**

LDAP - Slapindex

/opt/zimbra/openldap/sbin/slapindex -f /opt/zimbra/conf/slapd.conf

LDAP - Export & Reimport

1) su - zimbra
2) libexec/zmslapcat /tmp
3) mv /tmp/ldap.bak /tmp/ldap.ldif
4) zmcontrol stop
5) ps -aux | grep slapd **If ldap is still running, kill it**
6) su - root
7) mv /opt/zimbra/openldap-data /opt/zimbra/openldap-data.OLD
8) mkdir -p /opt/zimbra/openldap-data/logs && mkdir -p /opt/zimbra/openldap-data/accesslog/db
9) chown -R zimbra:zimbra /opt/zimbra/openldap-data/
10) su - zimbra
11) /opt/zimbra/openldap/sbin/slapadd -f /opt/zimbra/conf/slapd.conf -b "" -l /tmp/ldap.ldif 
12) zmcontrol start

Clear SA DB

This would be handy if you are getting a lot of false positives

/opt/zimbra/libexec/sa-learn -p /opt/zimbra/conf/ --dbpath /opt/zimbra/amavisd/.spamassassin/ --siteconfigpath /opt/zimbra/conf/spamassassin --clear


/opt/zimbra/libexec/sa-learn -p /opt/zimbra/conf/ --dbpath /opt/zimbra/amavisd/.spamassassin --siteconfigpath \ /opt/zimbra/conf/spamassassin --force -expire –sync

KeyTool Commands

keytool -list -keystore /opt/zimbra/mailboxd/etc/keystore -storepass `zmlocalconfig -s -m nokey mailboxd_keystore_password`

keytool -delete -alias jetty or tomcat -keystore /opt/zimbra/mailboxd/etc/keystore -storepass `zmlocalconfig -s -m nokey mailboxd_keystore_password`

Excessive Load Info Needed - What you need to show Zimbra Support

In general, when troubleshooting performance issues, we would like to know the following:
1. What exactly is slow?
2. Timestamps when problem is observed
3. Repro steps, if applicable
4. When the problem occurs, generate a few threaddumps (30 seconds apart) and send us zmmailboxd.out:
5. generate zmstat charts covering the times when the problem occurs

There are a few commands you can run to help us diagnose; the only stipulation is to run these commands *during* the excessive high load. We'll need to see what's going on during the high load.

1) Run the following command *during* the high load, run this command as root. This should write the output to the /opt/zimbra/log/zmmailboxd.out file.

for i in 1 2 3; do /opt/zimbra/libexec/zmmailboxdmgr threaddump; sleep 30; done

2) On the day of the excessive high load, we'll need you to generate graphs; this will help the engineers see any problems. Run as the zimbra user

zmstat-chart -s /opt/zimbra/zmstat/<day of the excessive load> -d /tmp/zmstats
tar -czvf /tmp/zmstats.tar.gz /tmp/zmstats

3) Find out the PID of the jetty process and run pstack on it, send us the results from the pstack command. Please run this command during the excessive load.

ps -ef | grep jetty
pstack <jetty_pid>

Sometime, Zimbra engineers need to know as much as possible about your machine in these types of excessive load situations. Using the script below could be helpful - no such thing as too much info. :)


if [ `whoami` != "zimbra" ]; then
echo "Must be executed as the zimbra user."
exit 1
zmcontrol -v

echo "Number of users"
echo "---------------"
zmprov gaa | wc -l


echo "Processor Version"
echo "-----------------"
PROC_VER=`cat /proc/version`
echo "$PROC_VER"


echo "Processor Info"
echo "--------------"
PROC_INFO=`cat /proc/cpuinfo`
echo "$PROC_INFO"

echo "Mem Info"
echo "--------"
FREE=`free -m`
echo "$FREE"
echo "`dmesg | grep Mem`"


echo "FSTAB File"
echo "----------"
echo "`cat /etc/fstab`"


echo "Mtab file"
echo "---------"
echo "`cat /etc/mtab`"


echo "Disk Space"
echo "----------"
echo "`df -h`"


echo "Threads"
echo "-------"
zmprov gacf | grep -i threads
echo "Message Cache Size"
echo "------------------"
zmprov gacf | grep zimbraMessageCacheSize
echo "Info from zmlocalconfig"
echo "-----------------------"
zmlocalconfig -d | grep java_options
zmlocalconfig -n | grep maxActive
zmlocalconfig | grep max_uncommitted_operations
zmlocalconfig | grep percent

echo "Mysql Info"
echo "----------"
grep max_connections /opt/zimbra/conf/my.cnf
grep innodb_buffer_pool_size  /opt/zimbra/conf/my.cnf
grep innodb_max_dirty_pages_pct  /opt/zimbra/conf/my.cnf
grep innodb_flush_method  /opt/zimbra/conf/my.cnf


echo "Java Process"
echo "------------"
ps -ef | grep java


echo "LDAP Info"
echo "---------"
/opt/zimbra/sleepycat/bin/db_stat -m -h /opt/zimbra/openldap-data | head -n 11


/opt/zimbra/sleepycat/bin/db_stat -m -h /opt/zimbra/openldap-data | head -n 12

Small Favor

Please install the following tools, sometimes the engineers use pstack and/or strace for troubleshooting.
1) pstack
2) strace

Enable Away Messages (Vacation)

1) Access your account using the web interface,
2) Once you have accessed your account, go to Preferences => Mail
3) If you scroll down in the Mail section, look for "Send auto-reply message:". You should then type your away message, and pick the start date and finish date.
4) Don't forget to click "Save" in the upper left hand.

Auto-Reply Not Working

Organizations using the Split-Domain configuration *may* encounter problems with the auto-replies not working.
Mail that is arriving to and the zimbra server only knows about So the code that tries not to send vacation message if the mail was not directly sent to the account kicks in. This is as intended. The "was it sent directly to this acct" check only checks To: and Cc: headers and not envelope RCPT TO address (as it should).


zmprov ma +zimbraPrefOutOfOfficeDirectAddress
zmprov ma zimbraPrefOutOfOfficeReplyEnabled TRUE

Apple's .Mac Mail Service

It was recently discovered Apple's .Mac Mail Service removes messages in the Trash from their server after one week. This is not configurable.

Directory Permissions on /tmp

It is possible that during ZCS install, if the /tmp directory does not have the correct permissions, it could hinder your efforts to install ZCS. Make sure the /tmp directory has the following permissions.

drwxrwxrwt 17 root root 4096 2008-07-07 08:33 tmp

If your /tmp permissions do not match the above, run the following commands as root:

# chmod 777 /tmp
# chmod +t /tmp

The "t" in the end of the permissions is called the "sticky bit". It replaces the "x" and indicates that in this directory, files can only be deleted by their owners, the owner of the directory or the root superuser. This way, it is not enough for a user to have write permission on /tmp, he also needs to be the owner of the file to be able to delete it.

Columns are MisMatch in the GAL using ZCO

1) Remove ZCO profile(s) from Outlook - Start ==> Control Panel ==> Mail

2) Once the ZCO profile is removed, go into the following directories and remove everything in the specified directories:
c:\documents and settings\<user>\local settings\application data\microsoft\outlook
c:\documents and settings\<user>\application data\microsoft\outlook

3) Recreate ZCO profile for Outlook - Start ==> Control Panel ==> Mail

Once you have recreated the zco profile, open Outlook, then have a look again at the GAL.

Manually Delete Index Directories

Ran across a case where the admin had to remove the index directories for a mailbox. Looking at the mailbox.log file, there was this error:
A couple of the symtoms are:
- The reindex of a mailbox runs too fast.
- When the user attempts a search in the ZWC, no results are found when there should be a result.

2008-07-18 00:13:52,477 INFO [MailboxPurge] [;mid=11;] index - ignoring error while deleting index entries for items: [-28865, 28865] Could not create index com.zimbra.cs.index.Z23FSDirectory@/opt/zimbra/index/0/11/index/0 (directory already exists)
 at com.zimbra.cs.index.Lucene23Index.openIndexWriter(
 at com.zimbra.cs.index.Lucene23Index.deleteDocuments(
 at com.zimbra.cs.index.MailboxIndex.deleteDocuments(
 at com.zimbra.cs.mailbox.Mailbox.commitCache(
 at com.zimbra.cs.mailbox.Mailbox.endTransaction(
 at com.zimbra.cs.mailbox.Mailbox.purgeMessages(
 Caused by: read past EOF
 at org.apache.lucene.index.SegmentInfo.<init>(
 at org.apache.lucene.index.SegmentInfos$1.doBody(
 at org.apache.lucene.index.SegmentInfos$
 at org.apache.lucene.index.IndexWriter.init(
 at org.apache.lucene.index.IndexWriter.<init>(
 at com.zimbra.cs.index.Lucene23Index.openIndexWriter(

While there are probably multiple situations where the index directory needs to be removed (or reindexed), this was one case I recently ran across.
To remove the index directories in this example, follow this method:

1) su - zimbra
2) rm -rf /opt/zimbra/index/0/11/index/0
3) zmmailboxdctl stop
4) zmmailboxdctl start
5) Then reindex the mailbox from the Admin Console.

Upper Case Letters in the hostname in /etc/hosts will prevent the install from continuing

Make sure the hostname in the /etc/hosts do not contain upper case letters. Or else the install will not continue.

Main menu

   1) Common Configuration:                                                  
        +Ldap master host:           
        +Ldap port:                            389                           
        +Ldap Admin password:                  set                           
        +Require secure interprocess communications: yes                           
        +TimeZone:                             (GMT-08.00) Pacific Time (US & Canada)

   2) zimbra-ldap:                             Enabled                       
   3) zimbra-store:                            Enabled                       
   4) zimbra-mta:                              Enabled                       
   5) zimbra-snmp:                             Enabled                       
   6) zimbra-logger:                           Enabled                       
   7) zimbra-spell:                            Enabled                       
   8) Default Class of Service Configuration:                                
   9) Enable default backup schedule:          yes                           
   r) Start servers after configuration        yes                           
   s) Save config to file                                                    
   x) Expand menu                                                            
   q) Quit                                    

Address unconfigured (**) items or correct ldap configuration  (? - help)

External Authentication with LDAP

Requires one of the following:
1) set
Set domain attribute zimbraAuthMech to ldap.
zimbraAuthLdapSearchBindPassword => bind DN of the admin user of the external directory
zimbraAuthLdapSearchBindDn => password of the admin user of the external directory
zimbraAuthLdapSearchBase (optional, if not set "" will be used).
Three things are needed for auth to the external LDAP server:
- URL of the LDAP server: zimbraAuthLdapURL
- password entered by user
- the bind DN for the user, this can be setup using one of the following 3 ways. (A) is preferred over (B) because (C) does an extra LDAP search.

(A) zimbraAuthLdapBindDn
This is the bind DN template

(B) zimbraAuthLdapSearchFilter
If set, then zimbraAuthLdapSearchBindPassword, zimbraAuthLdapSearchBindDn, and zimbraAuthLdapSearchBase also need to be set.
Server uses the four attrs to get the bind DN for the user.
Server first does a LDAP search using the zimbraAuthLdapSearchBindDn/zimbraAuthLdapSearchBindPassword credential by zimbraAuthLdapSearchFilter under zimbraAuthLdapSearchBase. The search would return the bind DN for the user, if found.
example for zimbraAuthLdapSearchFilter: (&(mail=%u@%d)(objectclass=person)) (whatever object class they are using)

(C) Account attribute zimbraAuthLdapExternalDn
Unlike (A) and (B), which are domain settings, this is an account level setting. This overrides the bind template and/or search setting, and directly contains the DN for the user in the external ldap server.


2) set
Set domain attribute zimbraAuthMech to ldap.
zimbraAuthLdapBindDn to the template filter for the user in the external directory.
For example, if the user exists at uid=jsmith,cn=users,dc=zimbra,dc=com , set zimbraAuthLdapBindDn on the domain to: uid=%u,cn=users,dc=zimbra,dc=com
Another example uid=%u,ou=people,%D (whatever LDAP DIT structure they are using)

zimbraAuthLdapBindDn and zimbraAuthLdapSearchFilter can contain expansion variables that are to be substituted by components in the account name:
%n = username with @ (or without, if no @ was specified)
%u = username with @ removed
%d = domain as
%D = domain as dc=foo,dc=com

e.g. for user
%n =>
%u => rking
%d =>
%D => dc=zimbra,dc=com

example for zimbraAuthLdapBindDn: uid=%u,ou=people,%D (whatever LDAP DIT structure they are using)

External Authentication Errors

525 - user not found
52e - invalid credentials
530 - not permitted to logon at this time
532 - password expired
533 - account disabled
701 - account expired
773 - user must reset password
775 - user account locked

Example in the /opt/zimbra/log/mailbox.log file:

Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 52e, vece^@]
        at com.sun.jndi.ldap.LdapCtx.mapErrorCode(
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(
        at com.sun.jndi.ldap.LdapCtx.connect(
        at com.sun.jndi.ldap.LdapCtx.<init>(
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(

Notable bugs:

Mix external authentication users with local users

Lets say, you are using external authentication; however, you would like to create a few users locally on the Zimbra system without provisioning users on the external authentication system (openldap, AD etc etc).

This should be possible with setting the following domain attribute.

zmprov md zimbraAuthFallbackToLocal TRUE

Sending Attachments

If you are having trouble sending attachments, and you *think* you've set the zimbraFileUploadMaxSize & zimbraMtaMaxMessageSize, correctly, then find out how much larger a MIME version of a file will be after base-64 encode.

If you want to find out just how much larger a MIME version of a given file will be, run the file through UUDeview (windows app) - try 'base 64' in the encode settings. Won't wreck your current file, it creates a converted duplicate. This should give you an idea of what values to use if you don't want to use an arbitrary value.

Removing older version inside /opt/zimbra

Can I delete older versions of software that is in the /opt/zimbra directory? I have older version of amavisd, clamav, cyrus-sasl, etc.

Answer: I am not sure *why* the prior versions are still around after an upgrade. The answer I received was, we (Zimbra), shouldn't remove things during an upgrade. My impression was this was a policy decision. I'd say move those older versions out of the way into another directory. And if there are no problems, I'd say you are good to go. To be honest, I am paranoid - I never suggest remove anything on a system. :)


The relevant docs are in /opt/zimbra/doc. The /opt/zimbra/doc directory has most (if not all) our docs for soap.
Regarding the URL using the admin soap stuff you need to talk to the admin server (by default port 7071).
Example for the admin url for soap:


Another point of interest: /opt/zimbra/conf/attrs/zimbra-attrs.xml

Hardware Support

In the server, one of the hard disks is showing a red light. It is Raid 5 configured. Not sure where to look.

Zimbra Support can't help very much here. We support the Zimbra software, not the server hardware or the OS RAID infrastructure. If it's a standard Linux RAID, you can remove it from the RAID group with mdadm, replace the device, and add a new device to replace it. If it's a separate array or something, you'll have to go to the manufacturer instructions to find the procedure for replacing the device. You'll probably find more information with a web search than you can get from us on this topic.

Zimbra Mobile and BIS

Customers using utilizing AT&T and Verizon for their Blackberry Internet Services (BIS) will need to make sure port 993 is accessible. Apparently, BIS services will authenticate using port 993. I had a case where the admin was using AT&T to setup an account; however, he was getting the "connection timed out" message, or "cannot authenticate" from the AT&T app. On a hunch I suggested opening port 993 through his firewall (because it wasn't accessible to the outside world) . After that was done, AT&T was able to authenticate.

Distribution Lists and Duplicates

The scenario is that you are a member of a distribution list, and also was CC'd separately, and you have noticed you have received two messages instead of one; send to:,

Have a look at the following global setting:

zmprov gacf | grep zimbraMessageIdDedupeCacheSize

If this setting was set to zero, that would probably explain the duplicates you may see.

If you need to suppress the duplicates, run this command:

zmprov mcf zimbraMessageIdDedupeCacheSize 3000
**3000 is the default**

This would require to restart Jetty services.

zmmailboxdctl restart
**be advised this would be a slight disruption of services. you may need to restart jetty during low-peak times, or after business hours.**

Change LDAP Log Levels

There are two methods.


zmlocalconfig -e ldap_log_level=256

ldap stop

ldap start


**this method does not require ldap stop/start**

ldapmodify -x -h <host> -D "cn=config" -W <hit enter>
<enter ldap_root_password>
dn: cn=config
changetype: modify
replace: olcLogLevel
olcLogLevel: 256 **if you want to disable ldap log, type in 'none'**
<enter> <enter>

Jump to: navigation, search