Friday, January 16, 2009

Coldfusion Connect Gmail with IMAP

What is IMAP? 

IMAP, or Internet Message Access Protocol, lets you download messages from Gmail's servers onto your computer so you can access your mail with a program like Microsoft Outlook Express or Apple Mail, even when you aren't connected to the Internet.

IMAP creates a constant connection between mail clients (desktop and/or mobile) and Gmail.
What's the difference between IMAP and POP? 

Unlike POP, IMAP offers two-way communication between your web Gmail and your email client(s). This means when you log in to Gmail using a web browser, actions you perform on email clients and mobile devices (ex: putting mail in a 'work' folder) will instantly and automatically appear in Gmail (ex: it will already have a 'work' label on that email the next time you sign in).

IMAP also provides a better method to access your mail from multiple devices. If you check your email at work, on your mobile phone, and again at home, IMAP ensures that new mail is accessible from any device at any given time.

Finally, IMAP offers a more stable experience overall. Whereas POP is prone to losing messages or downloading the same messages multiple times, IMAP avoids this through two-way syncing capabilities between your mail clients and your web Gmail.

If you're trying to decide between using POP and using IMAP with Gmail, we recommend IMAP.
How much does IMAP cost? 

IMAP for Gmail is free.
Great! How do I get started? 

First, you'll need to enable IMAP in Gmail. Once IMAP is enabled, follow the configuration instructions for your client of choice. Currently, only the clients listed are supported for IMAP. If you'd like to download your Gmail messages with a different client, please check to see if it's on our list of supported POP clients.

When you've enabled IMAP and set up your client, sign in to Gmail through the client and watch your messages arrive. You'll notice that all of your custom Gmail labels will appear in your client as folders, with your labeled messages inside. While we'd like to make your IMAP experience match the Gmail web interface as much as possible, some Gmail-specific features and terms, such as conversation threading and stars, won't appear in your client. Don't worry; you can still perform all the usual Gmail functions, just in a slightly different way. The IMAP behavior chart shows you how to perform common functions on your IMAP client.


Connecting to Gmail using ColdFusion
Do you want to build an integrated ColdFusion interface to Gmail? Using newbish's IMAP CFC client, it can be done. It just needs a couple modifications to work with Gmail's SLL IMAP.  Here's how...1. Enable IMAP in your Gmail account 2. Download the IMAP CFC from SourceForge.3. Make the following modifications to the imap.cfcOn line 7, add this... At the end of the init() function, add this...      Replace the GetStore() function with this one...                                          You do not have a mail account or there was a problem authenticating.        You can now use the CFC library to interface with Gmail's IMAP. Just make sure to pass the right arguments into the init function - The port has to be 993 for Gmail, and argument 6 should be a 1 (ssl enabled). The CFC will still work for non-SSL IMAP calls if you want to use it. Just pass a 0 in argument 6.Here's an example for Gmail... If you have a TON of e-mail in your Gmail Inbox, you might want to modify this code before you run it. Something like this... pass in just a few message IDs in the second argument of the list function. I can share more code if people are interested.
Please note that every client handles IMAP in a slightly different way. If you're curious about the specific use of your client, contact the client's support team.

No comments:

Post a Comment