IMAP, POP, and SMTP  |  Gmail  |  Google for Developers (2024)

For non-Gmail clients, Gmail supports the standard IMAP, POP, and SMTP protocols. The Gmail IMAP, POP, and SMTP servers have been extended to support authorization via the industry-standard OAuth 2.0 protocol.

Protocol

IMAP, POP, and SMTP use the standard Simple Authentication and Security Layer (SASL), using the built-in the native IMAP AUTHENTICATE, POP AUTH, and SMTP AUTH commands, to authenticate users. The SASL XOAUTH2 mechanism enables clients to provide OAuth 2.0 credentials for authentication. The SASL XOAUTH2 protocol documentation describes the SASL XOAUTH2 mechanism in great detail, and libraries and samples which have implemented the protocol are available.

Incoming connections to the IMAP server at imap.gmail.com:993 and the POP server at pop.gmail.com:995 require SSL. The outgoing SMTP server, smtp.gmail.com, supports TLS. If your client begins with plain text, before issuing the STARTTLS command, use port 465 (for SSL), or port 587 (for TLS).

Session length limits

Gmail POP sessions are limited to about 7 days. Gmail IMAP sessions are limited to about 24 hours. If the session was authenticated using OAuth credentials, it's limited to about the validity period of the access token used (usually 1 hour). A session in this context is one continuous TCP connection.

When the time elapses and the session expires, Gmail closes the connection with a message saying that the session expired. After that, the client can reconnect, authenticate again, and continue. If using OAuth, make sure that the access token used is valid (if you try to use an access token older than 1 hour, it might be invalid).

Libraries and Samples

Accessing mail using IMAP or POP and sending mail using SMTP is often done using existing IMAP and SMTP libraries for convenience. As long as these libraries support the Simple Authentication and Security Layer (SASL), they should be compatible with the SASL XOAUTH2 mechanism supported by Gmail.

In addition to the SASL XOAUTH2 protocol documentation, you may also want to read Using OAuth 2.0 to Access Google APIs for further information on implementing an OAuth 2.0 client.

The Libraries and Samples page provides code samples in a variety of popular languages using the SASL XOAUTH2 mechanism with either IMAP or SMTP.

IMAP, POP, and SMTP  |  Gmail  |  Google for Developers (2024)

FAQs

IMAP, POP, and SMTP  |  Gmail  |  Google for Developers? ›

IMAP, POP, and SMTP use the standard Simple Authentication and Security Layer (SASL), using the built-in the native IMAP AUTHENTICATE , POP AUTH , and SMTP AUTH commands, to authenticate users. The SASL XOAUTH2 mechanism enables clients to provide OAuth 2.0 credentials for authentication.

Should I enable both POP and IMAP in Gmail? ›

Step 1: Make sure POP is the best way to read your emails

IMAP can be used across multiple devices. Emails are synced in real time. POP can only be used for a single computer. Emails aren't synced in real time.

Can I have both IMAP and POP enabled? ›

Turn on POP, IMAP, or both—You can turn on POP and IMAP or turn them on independently of each other. Restrict which IMAP clients people can use—You can choose to allow all IMAP clients or specify only allowed clients.

Should I use IMAP or POP3? ›

IMAP is ideal for users who frequently check their email from multiple devices, such as desktops and smartphones, and want to have the same email experience on all of them. POP3 is more suited for users who primarily access their email from a single device and want to download messages for offline access.

Is Gmail SMTP port 465 or 587? ›

On the device or in the app, for server address, enter smtp.gmail.com. For Port, enter one of the following numbers: For SSL, enter 465. For TLS, enter 587.

What happens if I enable IMAP in Gmail? ›

With IMAP, you can read your Gmail on multiple devices, and messages and folders are synced in real-time. For the Gmail IMAP settings to work in your email client, IMAP access must be enabled in Gmail online.

What happens if I enable POP in Gmail? ›

After Gmail provides the list of messages to your mail client, your client will begin downloading them. In POP normal mode, Gmail provides a list of about 250 of the oldest messages that have not yet been downloaded (Spam and Trash are excluded). Once a message is downloaded, Gmail marks it as 'popped'.

Does anyone still use POP email? ›

Yes, email providers still use POP3 to provide email services — but its usage has declined over the years, mainly because it falls short in certain areas. Despite that, many users still choose POP3 as their main email protocol, but not if they want to manage their email on several devices.

Will I lose emails if I change from POP to IMAP? ›

Changing your email setup from POP to IMAP in the wrong order can cause your email to be deleted. In this guide, we explain how to do this safely.

Should POP and IMAP be disabled? ›

Legacy email protocols POP and IMAP are prone to brute force password spray attacks which may succeed in breaching the tenant's mailboxes. To best protect from this, we recommend you disable legacy email protocols for all new mailboxes.

Should I use POP IMAP or SMTP? ›

POP3 and IMAP are protocols for retrieving emails from a server, while SMTP is for transmitting emails. POP3 downloads messages directly to your device. In comparison, IMAP retains the message on the server. POP3 frees up storage space on servers, but IMAP frees up space on local hard drives.

Is IMAP outdated? ›

Warning: Using POP or IMAP server settings is strongly discouraged. Starting October 2022, Microsoft 365 accounts set up as POP and IMAP won't be able to connect to their mailboxes in email clients using Basic authentication. Basic authentication is an outdated industry standard that'll be deprecated.

Which is safer IMAP or POP? ›

They both have filters for spam and viruses. But, IMAP filters are more advanced compared to POP3. However, POP3 provides more privacy for users since it does not keep copies in the server once they receive the email.

Is port 587 SSL or TLS? ›

Port 587 is often used to encrypt SMTP messages using STARTTLS, which allows the email client to establish secure connections by requesting that the mail server upgrade the connection through TLS.

What is the correct SMTP for Gmail? ›

Summary
Gmail SMTP server addresssmtp.gmail.com
Gmail SMTP usernameYour full Gmail address (e.g. you@gmail.com)
Gmail SMTP passwordThe password that you use to log in to Gmail
Gmail SMTP port (TLS)587
Gmail SMTP port (SSL)465
1 more row
Apr 10, 2024

Why is port 25 blocked? ›

TCP port 25 is frequently blocked by Internet Service Providers (ISPs), as an anti-spam technique since it's used in MX spamming and abuse of open proxy/relay machines.

What happens if I change from POP3 to IMAP? ›

Switching a POP3 account to IMAP allows you to keep messages on the server, and to synchronize them to multiple IMAP clients. You just need to create a new IMAP account in your mail client, then drag any messages from your old POP3 account into the IMAP account if you'd like to retain them and remove the POP3 account.

Should I disable IMAP? ›

Legacy email protocols POP and IMAP are prone to brute force password spray attacks which may succeed in breaching the tenant's mailboxes. To best protect from this, we recommend you disable legacy email protocols for all new mailboxes.

What is the difference between POP and IMAP in GMail? ›

POP3 only allows a single device at a time to access the emails. IMAP allows multiple devices at a time to access and read the available mails. A user cannot update or create emails on the mail server by using the POP3 protocol. You can use the IMAP protocol for updating or creating emails.

Did GMail stop supporting POP3? ›

To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password. Thunderbird does access GMail via POP, **WITHOUT** 2-step verification.

Top Articles
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 5674

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.