Hi Lauren,
Yes, it appears that the issue in this server's case was either
- the email compression setting was enabled when the mailbox was created (and during much of its life), but the setting no longer is, or
- the hosting account was migrated from another cPanel server that has email compression enabled.
Rex gave me the following command to help determine if a mailbox has compressed contents. This should be executed with the working directory set to a mailbox maildir location, e.g. "
/home/{account}/mail/{domainname}/{mailbox}".
find . -type f -exec file {} \+ | awk -F ':[ ]+' '{ print $2; }' | sort | uniq -c | sort -n
If the mailbox contains any compressed messages you'll see this line in the response:
<count> gzip compressed data, from Unix
To decompress these messages I built this command. -- Obviously this
will increase the mailbox disk usage.
- Make a backup copy of the {mailbox} directory first.
- Really. Make a backup copy of the whole {mailbox} directory first.
- Are you sure you have a backup copy of the {mailbox} directory?
Again, run this with the working directory set to a mailbox maildir location.
for MSGFILE in $(find . -type f -exec file {} \+ | grep gzip | awk -F ':[ ]+' '{ print $1; }' | sort); do echo "${MSGFILE}"; gzip -c -d "${MSGFILE}" > "${MSGFILE}.plain"; if [ -s "${MSGFILE}.plain" ]; then echo "Success"; rm -f "${MSGFILE}"; mv "${MSGFILE}.plain" "${MSGFILE}"; else echo "Failed"; rm -f "${MSGFILE}.plain"; fi; done;
I'm sure a Bash guru could shorten that further, particularly the use of a temporary ".plain" file.
You will start seeing a list of email files, with either "Success" or "Failed" indicating if the message has been decompressed. Bare in mind there will be an expected (short) delay for the cPanel disk usage component to notice these changes.
----
You could wrap these commands up to work with all mailboxes for an account (all domains within) as follows, with your working directory to "
/home/{account}"
for DOMAINDIR in $(find . -maxdepth 1 -type d | sort); do if [ ! -d "${DOMAINDIR}/mail" ]; then continue; fi; for MSGFILE in $(find "${DOMAINDIR}/mail" -type f -exec file {} \+ | grep gzip | awk -F ':[ ]+' '{ print $1; }' | sort); do echo "${MSGFILE}"; gzip -c -d "${MSGFILE}" > "${MSGFILE}.plain"; if [ -s "${MSGFILE}.plain" ]; then echo "Success"; rm -f "${MSGFILE}"; mv "${MSGFILE}.plain" "${MSGFILE}"; else echo "Failed"; rm -f "${MSGFILE}.plain"; fi; done; done;
I've not tested this for multiple mailboxes at once though! Verify what I've written, and backup the mailbox directories first. (Only 2 mailboxes seemed to be impacted on the server in question so I just sorted those individually.)
----
Thanks again for your support on this issue.
