Filed under: Analysis / Opinion, Apple, iPhone
Prevent Spotlight from resurrecting your deleted emails on iPhone
Note: The problem discussed below behaves differently depending on the type of email account being used. Users of POP mail accounts are indeed noticing a problem with deleted email messages appearing in Spotlight search results. Please see this post for updated information.Our friends over at Engadget have highlighted a Cult of Mac post that, at first glance, appears to have found a bug in Spotlight's caching of email search results on the iPhone. The idea is that after you delete an email from your inbox in the iPhone's Mail.app client, you can still locate and open the e-mail using Spotlight search, if you know the subject of the message.
What's really happening, though, is what Apple might otherwise call "user confusion." When you delete an e-mail message in most mail clients, the message isn't magically deleted, but instead moved to a "trash" or "deleted messages" folder. Being a folder, it is indexed by Mail to provide an unread count, as well as by Spotlight so that you can easily find messages in the folder. When you search for the email, it shows up in Spotlight and opens in Mail because the message still exists in your trash folder.
All right, so what can you do to avoid this? Well, you need to empty the trash folder from your email. With many providers, you can just go to the trash folder, and delete the message from there to permanently remove it. The problem there is that, if you use a service like Gmail, the message doesn't really get deleted when you do this because of the way Gmail translates its labels into folders. Gmail's Trash folder is also set to purge itself after 30 days by default.
By now, you're probably wondering if this is really something to worry about. In my opinion, it really depends on how you manage your email. If you rarely delete messages, or you just delete things that are not of interest to you, they will most likely disappear from your trash folder after a specified time period that is set by your email provider (usually somewhere between 7 and 30 days.) However, if you intentionally delete messages with the idea that the message is unretreivable, then you should probably consider testing this out for yourself to see if it affects you. Again, with many providers, just periodically deleting the contents of the trash folder will do the trick. If you use Gmail, or your company's email services are hosted by Google, then you may need to log in to the web interface periodically to empty the trash, or you can look into the available configuration options, if you feel comfortable doing so.
So in reality, this isn't really a bug as much as it is what I would call "intended, but unexpected behavior." Many people simply forget that the trash folder exists, particularly on the iPhone where you don't always see it sitting off to the left hand side of your inbox. Checking your trash folder for any unintentionally deleted items, and cleaning out the old messages periodically, isn't really a bad habit to get into. With that said, however, I do think that Apple could improve this behavior by implementing some simple changes like adding an "Empty Trash" button to the trash folder, showing the count of all messages in the trash instead of just unread messages (so that it's easier to notice there are messages in there), and having Spotlight either ignore deleted messages like Leopard's Spotlight does, or at least indicate that they were found in the trash.
What are your thoughts on this? Do you consider this to be a bug, or do you think it's just a place that Apple could improve the experience on? Let us know in the comments!
Update: Leander Kahney has posted an update to the original Cult of Mac post that clarifies this issue a bit more. It seems that accounts using POP are configured by default to remove messages after one day or one week, thus causing them to continue to appear in Spotlight search results. Unfortunately, there isn't an option to remove them immediately, however, only after a day, one week, one month, or never. Because of this, Spotlight still sees them in the index, and Mail still contains a cached copy of the message until the time limit configured in the settings is reached.
If you'd like to check out this setting for yourself, go to the Settings app, tap on Mail, Contacts & Calendars, and choose the POP mail account you want to modify. Scroll down and choose Advanced, and the retention settings will be at the top of that page under Deleted Messages. It appears the default for a new account is to retain messages up to one week. So this is still the OS doing what it's configured to do, but there really should be an option to remove messages immediately here. If Apple were to add an option there, and/or remove Spotlight's ability to index deleted messages, the problem would be solved.
Update 2: After further investigation, it appears that some messages deleted on POP accounts do disappear from Spotlight, while others show up long after the message is deleted. I have conducted several tests on this situation, including on different versions of the iPhone OS, and have posted an update with details.


![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 2)
Ted said 1:40PM on 8-18-2009
Actually this post is based on a false premise, yes the post is true, but the bug has nothing to do with what was disclosed in the bug post. The bug is that if you delete the message from BOTH the folder it was in, and the Trash, it still shows up in Spotlight.
Reply
Michael Jones said 1:54PM on 8-18-2009
That is likely because the email still exists somewhere or because Mail.app hasn't updated the listing of the folders yet. In my testing, I deleted the message from the phone, and yes, the message still showed up in Spotlight at first. But after I verified the trash was emptied from within Gmail, I went back to Mail, opened the trash folder, and it refreshed the list. The email no longer appeared in Spotlight after that.
Problem is, Mail doesn't refresh a lot of the subfolders (like the Trash) unless you explicitly open them. It's still a problem, yes, but IMO it's more by design than by error. For those who delete messages that *really* want them gone, then checking the trash folder is a good idea just to be safe. I'd still love to see Apple improve on this a bit, and make Spotlight ignore deleted items.
Sven said 1:51PM on 8-18-2009
I agree, this post is not correct. Servers that map the trash perfectly, like Yahoo, also have this problem. If you move a message to the trash, it shows up on the Yahoo site in the trash as well. If you empty the trash, it's deleted from both the server and the iPhone trash folder. But spotlight can magically resurrect it.
Reply
Michael Jones said 2:15PM on 8-18-2009
I just saw Cult of Mac's update on this, and have updated the post. It seems that the issue is mostly specific to POP3 accounts, and the iPhone's retention of deleted mail.
Miller said 1:57PM on 8-18-2009
The story is incorrect (the other posters are correct). I can go into my iPhone 3.0 mail program, delete an email I downloaded via POP3 and empty the trash and it STILL shows up.
I love my iPhone, but I can no longer use it for work unless this gets fixed.
Reply
jennyp said 1:58PM on 8-18-2009
bizarre image to this one guys
Reply
darkpaw said 2:00PM on 8-18-2009
I think this is still a bug.
I use a normal everyday POP service for one of my email accounts. I have read a bunch of emails, and received a bunch of spam which I deleted. I then emptied the Trash on the iPhone.
On my desktop Mac, the emails download again (I have set the server to not delete the emails until my Mac reads them). I force the server to delete the emails and they are indeed gone.
Back on the iPhone, going into the Trash for that mail account shows no emails. Running Spotlight on the phone lists the spam emails I deleted. They still exist somewhere in the iPhone even though the Trash has been emptied and refreshed. If I select one of the Spotlight results, Mail launches and crashes. I would say this is a bug.
Reply
Miller said 2:07PM on 8-18-2009
I would agree.... a bug it is.
Once a message is deleted and the trash is emptied, the search should NOT let you find it again. I can't wait till Apple says its part of their new "Advanced Deleted Message Search Algorithm". LoL.
I am an Apple fanboy... but sheesh. :)
A User said 2:16PM on 8-18-2009
Not really a bug or feature. It is just how it is.
There are always a trash bin. If you don't dump it, you delete items always there.
iPhone is not a repository, the server will always hold the e-mail and its content. So, technically, it is still existed. Deleting from iPhone is moving away from the inbox.
In fact, no one for sure knowing those "e-mail" system will ever delete our emails.
Reply
richard said 2:22PM on 8-18-2009
I'm wondering if more time was spent researching the story to get the facts straight, or designing the picture to go with it?
Reply
Michael Jones said 2:38PM on 8-18-2009
I tested the problem, which was said to be an issue for all email accounts. I found that ensuring the messages were deleted and refreshing the trash folder did indeed remove the results from Spotlight, and I posted this article to clarify those points.
Cult of Mac has now posted an update, clarifying the problem and detailing that the issue mainly deals with POP3 accounts and a setting in the iPhone OS that retains deleted messages. I've already updated the post with this information.
Either way, the facts are straight, and as more information on the problem develops, we'll continue to update the post.
richard said 2:48PM on 8-18-2009
Thanks for re-reporting cult of mac posts. I'll be sure to just read their site in future. I'll come here for the laughs. My favorite part of this particular article:
"What are your thoughts on this? Do you consider this to be a bug…"
Marco said 2:25PM on 8-18-2009
This post is innacurate, please correct it or delete the post. The bug is there, I delete and delete and re-delete and spotlight still finds the email. So, please, I know you want to defend Apple (why? I don't know) but encouraging companies to fix their bugs (instead of explaining them away) is a good thing.
Reply
Michael Jones said 2:46PM on 8-18-2009
As it says in the post, word is that POP accounts are affected differently due to a retention setting in the OS.
And for the record, I have no interest in defending Apple. If they're in the wrong on something, I'm more than fine with calling them out on it. But much of the hype going around about this issue is simply by people who don't understand that the iPhone is simply finding messages that are in the trash, or retaining messages that have been deleted as per the defined retention settings. If there is indeed a bug in the way this is being handled, then I'll update the post, but for now it seems to be intended behavior.
I do believe Apple should change the way this works, no argument there.
Pasnbyu said 2:43PM on 8-18-2009
On a related note, I used a similar "feature" to resurrect mt Notes app after it began crashing immediately after opening. I used Spotlight search to find a Note by searching on a word I knew was in a Note. After opening the Note it found from the Spotlight results screen, the Notes app has worked ever since. I wonder if this "feature" will be "fixed" as well?
Reply
KenC said 3:54PM on 8-18-2009
Michael it's not just pop it's IMAP email as well. I tested this yesterday and it affects IMAP as well.
Secondly are you still trying to state that people are not clearing up their trash in their email accounts? It's a Spotlight bug it's not the idiocy of people not cleaning out their trash. Your comment above makes it seem that you still think that people are just simply NOT clearing out the trash. I ran Spotlight found the email I deleted and cleared out of trash (yesterday) clicked it took mail a bit to open it but sure enough it was open once I hit the back button it takes me to my "trash" list of email and sure enough that email IS NOT in that list. So it is caching that info somewhere DEEP inside the iPhone.
Apple even came out today saying they know this is a bug and it should be fixed in the 3.1 update how is it then the intended behavior?
Reply
kevin said 4:18PM on 8-18-2009
There are two aspects to "clearing" the trash. First is removing the message from the trash (e.g. emptying the entire folder or deleting a specific message from Trash) and Second is refreshing the trash folder on the iphone. Performing only the first step will not remove it from the spotlight search.
This is exactly the way IMAP works. Most folders (except the inbox) do not update themselves until the user accesses them.
I suspect that Apple's fix to this will simply be to have the trash folder automatically update itself just as the inbox does.
Michael Jones said 5:27PM on 8-18-2009
Ken,
When it comes to IMAP, Kevin is right. You have to empty the folder, *and* refresh it before Spotlight picks up on the changes. Once the email is completely deleted, and the folder(s) it was in have been refreshed, then Spotlight won't find it anymore.Yeah, it's a big PITA, but really, that's how IMAP works in general... the app has to periodically poll the folders or be manually refreshed before it knows that an email is no longer there.
With POP, however, I did some digging and found out there is indeed a bug there, it just doesn't happen every time, and I guess I was lucky enough for it to work fine the first time I tried it. When using POP, the client marks the email as deleted, but never fully deletes the message and so it continues to show up under Spotlight's results. Luckily, Apple has already fixed that problem in the 3.1 update though.
badtzmaru said 4:25PM on 8-18-2009
what an inconsequential "bug" / "feature"
Reply
Patrick Coffey said 5:55PM on 8-18-2009
There is still a problem. I use exchange server and I know for a fact that my trash can is empty both on my iphone, outlook, and outlook webmail. But still spotlight shows that I have messages in my trash can. When I click on the message, the body of the message says "This message has not been downloaded from the server". Clearly there is a bug in 3.0
Reply