MailCore is a Cocoa e-mail framework built by Matt Ronge that is the core of the e-mail client Kiwi. MailCore provides a nice set of objects for working with IMAP, MIME and SMTP, all of which use the C e-mail library LibEtPan. Here is some short information about MailCore. This is short documentation on MailCore from Matt Ronge. Official website is here.
To make it run on your iOS simulator, do the following:
- Download MailCore from GitHub:
1234git clone https://github.com/mronge/MailCore.gitcd MailCore/git submodule initgit submodule update - Build m4, autoconf, automake, libtool on Mac OS X Lion using this post.
- Run update.sh script in MailCore to build and install everything before opening it in Xcode. If you don’t know, how to run shell scripts, read this
- Open MessageSender project in MailCore library. Select MessageSender to build. It will not do anything. To make it sending a test message write the following code in ViewDidLoad:
1234567891011121314151617181920212223CTCoreMessage myMessage = [[CTCoreMessage alloc] init];// Set ToCTCoreAddress *addrTo1 = [CTCoreAddress address];[addrTo1 setEmail:@"Your E-mail1"];CTCoreAddress *addrTo2 = [CTCoreAddress address];[addrTo2 setEmail:@"E-mail2"];/*CTCoreAddress *addrTo3 = [CTCoreAddress address];[addrTo3 setEmail:@"E-mail3"];*/[myMessage setTo:[NSSet setWithObjects:addrTo1, addrTo2, nil]];// Set FromCTCoreAddress *addrFrom = [CTCoreAddress address];[addrFrom setEmail:@"Your E-mail"];[addrFrom setName:@"Your Name"];[myMessage setFrom:[NSSet setWithObject:addrFrom]];[myMessage setSubject:@"Test Mail Core"];[myMessage setHTMLBody:@"This is a test HTML message"];[CTSMTPConnection sendMessage:myMessage \server:@"smtp.mail.ru" username:@"YourUserName" \password:@"YourPassword" port:587 useTLS:YES useAuth:YES]; -
Use this method to retrieve message subjects from Inbox of your mail:
1234567891011121314151617- (IBAction)retrieveClicked:(id)sender {CTCoreAccount *account = [[CTCoreAccount alloc] init];[account connectToServer:@"imap.yandex.ru" port:143 \connectionType:CONNECTION_TYPE_PLAIN authType:IMAP_AUTH_TYPE_PLAIN \login:@"YOUR USERNAME" password:@"YOUR PASSWORD"];NSSet *subFolders = [account subscribedFolders];CTCoreFolder *inbox = [account folderWithPath:@"INBOX"];NSSet *messageList = [inbox messageObjectsFromIndex:1 \toIndex:0];for (CTCoreMessage *message in messageList) {NSLog(@"%@", [message subject]);}}