OS X Users Losing Mail in Squirrelmail
Problem
We use Squirrelmail to provide a Web interface to our email. Our server runs Sendmail, POP3 and IMAP4. Yesterday, one user reported that when he opened his Inbox with Squirrelmail, it was empty. The user was very upset because all his mail had apparently been lost. The fault, according to the user, was a bug in Squirrelmail.
Here are the symptoms:
- Opening squirrelmail was very slow--at least 30 seconds, even though only 12 messages were visible.
- As soon as squirrelmail was opened, the user's Inbox size decreased from 2kB to 0. (Inbox is a single file in /var/spool/mail whose name is the same as the user's login name.)
- New emails were correctly received, but after a few seconds they disappeared from the user's /var/spool/mail file when he logged in with Squirrelmail, even before any message was opened. However, the message was still visible in his browser and could still be read.
- The user was running OS X and reported that other mail-reading clients, including something called "Mail.app", were working fine.
- Squirrelmail was working perfectly for all other users.
Solution
Upon inspection of the user's home directory, we found a strange file named "mbox". Since the user had never logged in on the server, it was easy to find, as it was the only file present. This "mbox" was a normal mail file in (not surprisingly) mbox format, about 300 MB in size, which contained all of the user's mail for the past six months. Whenever a new email came in, it first went to the user's Inbox in /var/spool/mail, as it is supposed to. However, when the user logged in with Squirrelmail, Inbox was immediately truncated to zero length and the new message was appended to the "mbox" file, thus making it inaccessible to all mail applications. Clicking "refresh" in the browser produced a screen with no mail visible.
There was nothing in any of the config files that mentioned any file named mbox. The user had not changed the default configuration.
Luckily, the mbox file was in the correct format for the server to parse, and when I moved it back to its proper location in /var/spool/mail, the user suddenly had 742 pages of mail in his Inbox. The slow login times had been caused by the need for Squirrelmail to download, read and parse the 300 MB file, which contained over 11,000 messages. Yet only 12 or 13 of those messages were being displayed on his browser. Once the mbox file was deleted, the speed returned to normal and the user's mail stopped disappearing.
Why did this Mac software suddenly start moving all the mail to some random file in the user's home directory? There's nothing in any of the Squirrelmail scripts and nothing on the server that could have caused this. The only explanation is that OS X somehow recognized that the browser was reading email, and automatically decided to pull a Mac stunt. When will programmers learn? Users' computers are messed up enough without applications going off and doing things on their own. Software should never change anything without the user being aware of it.
Update
We recently found that this can also happen to Windows users using PC-Pine. If users complain about their inbox being empty, check for a big mbox file in their home directory.