This document explains how to manage POP and IMAP protocols using the Gmail API.
POP and IMAP are two ways to read your Gmail messages in other email clients. POP is an older protocol designed for a single computer. With POP, your client downloads messages, and you choose how often to download new ones. IMAP works across multiple devices and syncs messages in real time.
You can use the
settings resource of
the Gmail API to configure how Gmail handles POP and
IMAP protocols:
POP
You can manage POP settings for an account using the
PopSettings object.
Enable and disable access
Control access with the
accessWindow
field. This field determines whether POP is enabled and which messages the API
retrieves.
| Value | Effect |
|---|---|
disabled |
No messages are accessible through POP |
allMail |
All unfetched messages are accessible through POP |
fromNowOn |
Only new messages are accessible through POP |
Message disposition
Configure the disposition of messages that the API retrieves with the
disposition
field.
| Value | Effect |
|---|---|
archive |
Move messages out of the INBOX |
leaveInInbox |
Do nothing; leave messages unread in the INBOX |
markRead |
Leave messages in the INBOX and mark them as read |
trash |
Move messages to the TRASH |
IMAP
You can manage IMAP settings for an account using the
ImapSettings object.
Enable and disable access
Use the boolean
enabled
field to control access. This field determines whether IMAP is enabled for the
account.
Message disposition
Use the
expungeBehavior
field to configure the disposition of a message when a client marks it as
deleted and expunges it from the last visible IMAP folder.
| Value | Effect |
|---|---|
archive |
Move messages marked as deleted out of the INBOX |
deleteForever |
Permanently delete messages marked as deleted |
trash |
Move messages marked as deleted to the TRASH |
If the boolean
autoExpunge
field is true, Gmail immediately expunges a message when a
client marks it as deleted in IMAP. Otherwise, messages remain until the IMAP
client explicitly requests their removal.
Related topics
- IMAP, POP, and SMTP for the Gmail IMAP API
- Choose your IMAP email client settings for Gmail
- Read Gmail messages on other email clients using POP