GMail POP3 Authentication — Must Unlock Captcha

If captcha is enabled on your GMail account (and it is enabled by default), then GMail POP3 authentication will fail with this error (even though a correct login/password is provided)

**** Connected to pop.gmail.com:995
< +OK Gpop ready for requests from 57.215.212.123 c23pf1097242ibu.22
> USER myaccount@something.com
< +OK send PASS
> PASS ****
< -ERR [AUTH] Username and password not accepted.

To successfully authenticate with pop.gmail.com from an email client such as Outlook, Thunderbird, or an application using Chilkat one must first unlock captcha:

  1. From the computer on which your signins are failing, visit http://www.google.com/accounts/DisplayUnlockCaptcha
  2. Enter your Gmail username and password, and the letters in the distorted picture.
  3. Once you have successfully signed in, retry running your application using Chilkat.

Note: Unlocking captcha is not required to access a GMail account via the IMAP protocol (imap.gmail.com).

GMail Labels are just IMAP Mailboxes

Question:
I’m going to be using them in VB.Net to process a GMail inbox. In GMail they use Labels instead of folders. Are the labels that belong to an email visible via your tool?

Ideally the VB application would process the inbox, and perform actions based on the label.

Answer:
I investigated and it refreshed my memory. GMail “labels” are just IMAP mailboxes. You can refer to the samples at http://www.example-code.com for VB.NET –> IMAP. You’ll find examples that list the mailboxes on the server. If you run it, you’ll see the labels listed. For example:

INBOX
Trash
[Gmail]
[Gmail]/All Mail
[Gmail]/Drafts
[Gmail]/Sent Mail
[Gmail]/Spam
[Gmail]/Starred
[Gmail]/Trash

Deleting email in GMail

(A tip from a Chilkat customer.)

The only way to delete emails on Gmail is in three steps:

1. Copy the email(s) to the folder called [Gmail]/Trash
2. Select all of the emails in [Gmail]/Trash and set the Deleted flag
3. Execute ExpungeAndClose or Expunge command

I found that this is the only way to truly delete emails from Gmail.

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.

GMail Settings for POP3 and IMAP Access

The most common problem with reading email from GMail using Chilkat’s POP3 and IMAP API’s is the following: The user can see certain emails when interactively logged onto GMail with a web browser, but cannot see those emails using Chilkat’s POP3 or IMAP component.

The problem is caused by a setting in your GMail account. The default setting causes an email to NOT be seen once it has been downloaded by a POP3 or IMAP client. You’ll need to change your GMail account setting for “Forwarding and POP/IMAP” access. The option to choose is this:

When messages are accessed with POP: Keep GMail’s copy in the Inbox

See the screenshot below:
GMail settings