Increasing the Size of Uploads and Attachments

A default Kolab environment uses default configuration for operating system packages, as they are shipped by your operating system vendor. This includes settings that limit the size of uploads accepted by the web server, and the maximum size of email messages.

This article outlines how to increase the mail and file size accepted.

Default Limitations

The following table depicts some typically common default limitations for applications used by a Kolab environment. Typically common, because different Linux distributions may ship with different defaults.

ApplicationDescriptionCommon Default Limitation
PostfixMaximum size of email messagesApproximately 10 MB
PHPMaximum size for file uploads2 MB
PHPMaximum size of POST requests8 MB
PHPMaximum number of individual files20
PHPMaximum memory used128 MB
MariaDB / MySQLServer-side maximum size of communication buffer1 MB, 4 MB or 16 MB
MemcachedMaximum item size1 MB

A Note About Distributed Environments

A distributed environment, such as a Kolab environment with multiple webmail servers, uploaded files are typically stored in two ways;

  • Files are uploaded to the local web server filesystem until at least the upload is successfully completed,
  • Files are sent off to networked, centralized storage such as MariaDB, to cover scenarios of intermediate web server availability and/or non-sticky load-balancing configurations.

The inherent requirement on uploaded files being available to all rotation participants through networked, centralized storage technology incurs the MariaDB / MySQL / Memcached maximum item size be taken in to account.

Alternatives would include running /var/lib/roundcubemail/off of NFS, GlusterFS or any other such filesystem distribution technology.

File Uploads

File uploads are limited primarily by PHP settings for upload_max_filesize and post_max_size. Since these are in binary, you should specify the exact value not accounting for much overhead.

Please note that the number is ultimately represented in the web client UI, including for attachments to email messages. If Postfix does not allow the maximum message size to be at or near the specified limit in PHP, users may be presented with unexpected results.

Please also note that larger file uploads are probably well-served with the APCu extension used for upload progress reporting.

Depending on your Linux distribution, the settings you need to modify can usually be found with;

# grep -rn ^upload_max_filesize /etc/php*

It does not hurt to modify all occurrences you may find (Debian, Ubuntu systems), unless you run something special and there’s little need for you to be reading this article in the first place.

Email Messages

The size of files attached to emails are commonly misrepresented when compared to the size of the message actually transferred. This has to do with the encoding used, and mail messages usually using base64 and not binary. This means that the maximum message limit configured needs to be at about 1.37 times the size of the file size in binary.

It is also worth noting that increasing message size limitations for Kolab users could cause some larger messages to not be accepted by third party recipients that use a lower message size limitation.

At the time of this writing, a widely accepted message size limit is 20 MB, meaning the file attached to a message could be about 14 MB maximum. Some common email providers support individual files up to 20-25 MB even if the message size limitations themselves may stretch to 150 MB or so, and most commonly message sizes are limited to 20-25 MB.

To configure the Postfix message size limitation on a global level, use the following command:

# postconf -e 'message_size_limit=20480000'
# postfix reload
Posted in Guides and tagged , , , .