Understanding GMail’s Behavior

This blog post will explain GMail in a way that will help you understand it’s seemingly strange behavior. The question that prompted this post is as follows:

I am able to read mails from GMail mailbox using MailMan object. Is there any options to delete a mail permanently from GMail mailbox? When I am using the DeleteMail method the mail is going to the Trash folder, however I want it to be deleted permanently.

To explain GMail, I’ll first describe Outlook and then compare it to GMail.  Even though you already “know” Outlook, please read this because it’s important when comparing it to GMail.

Outlook is an email client application that runs on your computer.  It communicates with an email server to download emails.  The emails you’ve downloaded may or may not be deleted from the server, depending on your Outlook settings.  Outlook keeps it’s own “database” of emails saved locally on your filesystem.  These are the local folders: Inbox, Trash, Junk, etc. and the folders you’ve created.  Emails may be deleted from the mail server (POP3 or IMAP) but they will still be present in Outlook’s local storage.

GMail has the exact same model.  (I’ll explain)   GMail is an email application that runs on a Google server (not on your local computer).  The user interface is within a web browser.  Just like Outlook, the GMail application (running on Google’s web server) is an email client that communicates with a mail server.  In this case, it is Google’s mail server offering both POP3 and IMAP access.  (pop.gmail.com and imap.gmail.com)

Just like Outlook, the GMail application communicates with the mail server to download email messages, which it stores in it’s own local “database”.  (I double-quote the word database because it’s really just some sort of proprietary persistant storage of emails.)   What you see in the GMail web interface are the emails NOT on the mail server, but in the local folders of the GMail application — just like Outlook.

Looking at it this way should clear up the confusion.  If you delete an email via the GMail web user-interface, you are not deleting the email on the mail server,  you’re deleting the GMail application’s local copy.  If a POP3 or IMAP client (such as Chilkat) deletes an email from pop.gmail.com or imap.gmail.com, it is NOT deleting the GMail application’s local copy.  Expecting a POP3 or IMAP client component/library to delete the GMail application’s local copy is the same as expecting the component to delete Outlook’s local copy.  Email clients communicate with email servers.  Outlook and GMail are email client applications.  The Chilkat email component is also an email client.  Clients do not talk to clients.  Clients talk to servers.  GMail is a client, it can talk to pop.gmail.com and imap.gmail.com.  The same goes for Outlook, Mozilla Thunderbird, and the Chilkat components.

If you look at the GMail POP Download settings, it should now make sense to you:

GMail POP settings

The GMail application offers options just like Outlook — but the terminology they’ve chosen is confusing:

“Keep Gmail’s copy in the Inbox” really means “Do not delete the mail server’s copy”.

“Delete Gmail’s copy” really means “Delete the email from the mail server”.

I’m not sure what “archive GMail’s copy” is — I’d need to experiment.  It probably means something like: move the email to another folder on the mail server.  Perhaps an archive folder which can be accessed via the IMAP protocol.