How to fix: "imap - BAD maximum literal size exceeded", in Zimbra.

I am new to Zimbra, and i had no chance to find a solution by using Google or any other way, because there simply was nothing to find. So i have created this post, because i know how much time i would have saved, if i had found a similar post back then.

After a customer migration from one mail-platform to another (Zimbra), a few of the clients experienced the following error:

imap - BAD maximum literal size exceeded

It was due to that they had moved an e-mail from their old inbox to their knew inbox, with a size of attachment which were bigger than Zimbra allowed. That was pretty easy to figure out, although the error message is a bit cryptic.

We could track the error responses in the mailbox.log-file, which is handy in general when debugging in Zimbra. So i ran the following tail (-f for follow) and grep'ed all warnings only:

# tail -f log/mailbox.log | grep -i warn

Then i could see errors, like the following, which were the error the clients experienced aswell:

2014-08-15 15:55:50,512 WARN [ImapServer-44] [name=mail@domain.tldmid=1076;ip=10.102.6.60;oip=10 .102.6.252;via=Microsoft Outlook for Mac/14.4.1 (140326),10.102.6.60(nginx/1.2.0-zimbra);ua=Zimbra/8.0.7_GA_6021;] imap - BAD maximum literal size exceeded

To fix it i used the CLI tools from Zimbra, mostly zmprov. The provisioning tool (http://wiki.zimbra.com/wiki/Zmprov). I used the getConfig parameter to see the value of four variables in Zimbra, which defines allowed mail sizes in different ways:

# zmprov getConfig zimbraFileUploadMaxSize
# zmprov getConfig zimbraImapMaxRequestSize
# zmprov getConfig zimbraMailContentMaxSize
# zmprov getConfig zimbraMtaMaxMessageSize

These are the values we need to edit. Note what the defaults is, so you change back, if you create new errors.

Determine what your customers biggest e-mail is, in my case 150M circa. I used TeamViewer to take a look in their mail client.

So i changed these values to 150M, in bytes; 150000000:

# zmprov modifyConfig zimbraFileUploadMaxSize 150000000
# zmprov modifyConfig zimbraImapMaxRequestSize 150000000
# zmprov modifyConfig zimbraMailContentMaxSize 150000000
# zmprov modifyConfig zimbraMtaMaxMessageSize 150000000

Confirm that the values are set:

# zmprov getConfig zimbraFileUploadMaxSize
# zmprov getConfig zimbraImapMaxRequestSize 
# zmprov getConfig zimbraMailContentMaxSize
# zmprov getConfig zimbraMtaMaxMessageSize
# postconf message_size_limit

Now, if everything looks great, reload postfix and restart the mailboxd service. Be careful that there is not too many connections, although you should not loose any data:

# postfix reload
# zmmailboxdctl restart

Validate that the errors are not visible anymore, by following your mailbox.log-file for a while:

tail -f log/mailbox.log | grep -i warn