98. Fetching emails using IMAP

The Internet Message Access Protocol (IMAP) is an internet protocol for retrieving email messages from an email server using TCP/IP. Most email server providers, including major ones like Gmail, Outlook.com, and Yahoo! Mail offer support for it. There are some C++ libraries for working with IMAP, such as VMIME, that is open source and cross-platform and supports IMAP, POP, and SMTP. However, in this book, I will use cURL (or more specifically, libcurl) to make HTTP requests to an email server using IMAPS.

The required operations can be achieved with several IMAP commands. In the following list, imap.domain.com is an example domain:

  • GET imaps://imap.domain.com retrieves all of the folders in the mailbox. If ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.