Skip to content
MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
C++ C Objective-C Objective-C++ Java Shell Other
Branch: master
Clone or download


Type Name Latest commit message Commit time
Failed to load latest commit information.
build-android Fixed build with ndk 13 Nov 23, 2016
build-linux Updated README instructions: removed uchardet dependency Jan 23, 2015
build-mac Remove deprecated ALWAYS_SEARCH_USER_PATHS setting for iOS target (#1757 Jun 18, 2018
build-windows Add possibility of fetching message attachment by chunks and store it… Jun 6, 2016
cocoapods Remove crypto & ssl libraries in podspec for osx (#1619) Mar 13, 2017
example Fix permission access of source files that was executable .i.e. chmod… May 17, 2016
resources Changed outlook SMTP port order in providers.json (#1723) Apr 26, 2018
scripts Exclude driverkit SDK from macosx sdk version variable. (#1855) Jan 5, 2020
src Fix superclass for MCONNTPDisconnectOperation (#1852) Dec 16, 2019
tests-ios Recent SDK requires setting rootViewController Feb 5, 2016
tests Fixed build on Linux Feb 9, 2016
unittest Removed test data Jan 4, 2018
.gitignore new xcode files Jan 3, 2017
.gitmodules Removed libjson submodule May 13, 2013
.travis.yml Fix travis build Sep 19, 2018
CMakeLists.txt Fixed tidy header file name (#1546) Oct 29, 2016
LICENSE License organization May 30, 2013 Doc update (#1611) Feb 16, 2017 added todo item May 26, 2013
mailcore-schema.svg Moved the quickstart guide over to the readme, added Hoa's mailcore s… May 28, 2013
mailcore2-ios.podspec.json Update podspec to point to a release that exists. Oct 1, 2018
mailcore2-osx.podspec.json Update podspec to point to a release that exists. Oct 1, 2018

MailCore 2: Introduction

MailCore 2 provides a simple and asynchronous Objective-C API to work with the e-mail protocols IMAP, POP and SMTP. The API has been redesigned from the ground up. It features:

  • POP, IMAP and SMTP support
  • RFC822 parser and generator
  • Asynchronous APIs
  • HTML rendering of messages
  • iOS and Mac support

Build Status


Build for iOS/OSX

Read instructions for iOS/OSX.

Build for Android

Read instructions for Android.

Build for Windows

Read instructions for Windows.

Build for Linux

Read instructions for Linux.

Basic IMAP Usage

Using MailCore 2 is just a little more complex conceptually than the original MailCore. All fetch requests in MailCore 2 are made asynchronously through a queue. What does this mean? Well, let's take a look at a simple example:

    MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
    [session setHostname:@""];
    [session setPort:993];
    [session setUsername:@""];
    [session setPassword:@"123456"];
    [session setConnectionType:MCOConnectionTypeTLS];

    MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaders;
    NSString *folder = @"INBOX";
    MCOIndexSet *uids = [MCOIndexSet indexSetWithRange:MCORangeMake(1, UINT64_MAX)];

    MCOIMAPFetchMessagesOperation *fetchOperation = [session fetchMessagesOperationWithFolder:folder requestKind:requestKind uids:uids];

    [fetchOperation start:^(NSError * error, NSArray * fetchedMessages, MCOIndexSet * vanishedMessages) {
        //We've finished downloading the messages!

        //Let's check if there was an error:
        if(error) {
            NSLog(@"Error downloading message headers:%@", error);

        //And, let's print out the messages...
        NSLog(@"The post man delivereth:%@", fetchedMessages);

In this sample, we retrieved and printed a list of email headers from an IMAP server. In order to execute the fetch, we request an asynchronous operation object from the MCOIMAPSession instance with our parameters (more on this later). This operation object is able to initiate a connection to Gmail when we call the start method. Now here's where things get a little tricky. We call the start function with an Objective-C block, which is executed on the main thread when the fetch operation completes. The actual fetching from IMAP is done on a background thread, leaving your UI and other processing free to use the main thread.



MailCore 2 is BSD-Licensed.

You can’t perform that action at this time.