GithubHelp home page GithubHelp logo

mailcore / mailcore Goto Github PK

View Code? Open in Web Editor NEW
826.0 68.0 221.0 22.53 MB

MailCore 1.0 is a Mac/iOS framework for working with the e-mail protocols IMAP and SMTP.

Home Page: http://www.libmailcore.com

License: Other

Objective-C 96.65% CSS 0.56% XSLT 1.16% Shell 0.39% Python 0.18% C 1.06%

mailcore's Introduction

 __    __     ______     __     __         ______     ______     ______     ______    
/\ "-./  \   /\  __ \   /\ \   /\ \       /\  ___\   /\  __ \   /\  == \   /\  ___\   
\ \ \-./\ \  \ \  __ \  \ \ \  \ \ \____  \ \ \____  \ \ \/\ \  \ \  __<   \ \  __\   
 \ \_\ \ \_\  \ \_\ \_\  \ \_\  \ \_____\  \ \_____\  \ \_____\  \ \_\ \_\  \ \_____\ 
  \/_/  \/_/   \/_/\/_/   \/_/   \/_____/   \/_____/   \/_____/   \/_/ /_/   \/_____/ 

What is MailCore

MailCore is a Mac and iOS library designed to ease the pain of dealing with e-mail protocols. MailCore makes the process of sending e-mail easy by hiding the nasty details like MIME composition from you. Instead, there is a single method required to send a message. Checking e-mail on an IMAP server is a more complex beast, but MailCore makes the job much simpler by presenting everything as a set of objects like Messages, Folders and Accounts.

Example

This example shows how you can send email using MailCore.

CTCoreMessage *msg = [[CTCoreMessage alloc] init];
CTCoreAddress *toAddress = [CTCoreAddress addressWithName:@"Monkey"
                                                    email:@"[email protected]"];
[msg setTo:[NSSet setWithObject:toAddress]];
[msg setBody:@"This is a test message!"];
 
NSError *error;
BOOL success = [CTSMTPConnection sendMessage:testMsg 
                                      server:@"mail.test.com"
                                    username:@"test"
                                    password:@"test"
                                        port:587
                              connectionType:CTSMTPConnectionTypeStartTLS
                                     useAuth:YES
                                       error:&error];

Getting the code

First checkout the code and pulldown the required dependencies as submodules:

git clone https://github.com/mronge/MailCore.git
cd MailCore/
git submodule update --init

Now open up MailCore.xcodeproj and build either the iOS static library or the Mac OS X framework depending on your needs.

Adding MailCore to Your iOS Project

  1. First checkout the latest code and make sure you get the required submodules
  2. Locate MailCore.xcodeproj and add it to your project as a subproject. You can do this by dragging the Mailcore.xcodeproj file into your Xcode project.
  3. Navigate to your app’s target and switch to your app’s Build Phases. Once in Build Phases expand “Link Binary With Libraries” and click the + button. And add these libraries:
   libmailcore.a
   libssl.a
   libsasl2.a
   libcrypto.a
   libiconv.dylib
   CFNetwork.framework
  1. Add “MailCore iOS” under “Target Dependencies”
  2. Under your app’s target, switch to Build Settings. Locate “Header Search Paths” in the Build Settings and add "$(BUILT_PRODUCTS_DIR)/../../include"
  3. You are now ready to use MailCore. To use MailCore add #import <MailCore/MailCore.h> to the top of your Objective-C files.

Adding MailCore to Your Mac Project

  1. First checkout the latest code and make sure you get the required submodules
  2. Locate MailCore.xcodeproj and add it to your project as a subproject. You can do this by dragging the Mailcore.xcodeproj file into your Xcode project.
  3. Navigate to your app’s target and switch to your app’s Build Phases. Once in Build Phases expand “Link Binary With Libraries” and click the + button. From there add MailCore.framework.
  4. While still under Build Phases click “Add Build Phase” in the lower right and select “Add Copy Files”. A new copy files phase will be added, make sure the destination is set to “Frameworks”. Now add MailCore.framework to that copy files phase by using the + button.
  5. Add “MailCore” under “Target Dependencies”
  6. You are now ready to use MailCore. To use MailCore add #import <MailCore/MailCore.h> to the top of your Objective-C files.

More Docs

Consulting

Consulting services are available via Astro HQ. At Astro HQ we have years of experience working on email apps. If you need custom e-mail functionality developed, please get in touch via our website.

Thanks,

Matt Ronge
@mronge

mailcore's People

Contributors

dangonz avatar devstator82 avatar droppery avatar gdonelli avatar ghdk avatar henningj avatar holtwick avatar jdg avatar jwilling avatar lyonanderson avatar mkdynamic avatar mronge avatar nzkoz avatar pitiphong-p avatar rgigger avatar scottnonnenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mailcore's Issues

Bad Mem Access when a file in an email doesn't have a filename

Sometimes a file will arrive with no filename property set. Calling decoded filename on such an attachment results in a memory access crash -- the nil pointer is converted to a char* and used for comparison, which causes the crash.

One potential fix is:

-(NSString *)decodedFilename {
if (self.filename) {
return MailCoreDecodeMIMEPhrase((char *)[self.filename UTF8String]);
}
else {
return nil;
}
}

You could also be smarter about it and return a generic filetype with the correct ending based on the mime type.

SMTP with Yahoo mail does not work

SMTP with Yahoo doesn't seem to work. I used the following configuration

[CTSMTPConnection initWithServer:@"smtp.mail.yahoo.com"
username:@"myusername"
password:@"mypass"
port:465
useTLS:YES
useAuth:YES];

I get 'Unexpected error code'.

Logging doesn't seem to give any good hint.
I've also tried it with different combinations below but none works.

  1. username with full email address, and with just the username before @yahoo.com
  2. with and without useTLS
  3. with and without useAuth
  4. port 587

send >>>>>>

15 UID STORE 5 FLAGS.SILENT (\Seen)

end send >>>>>>

<<<<<<< read <<<<<<

15 OK UID STORE completed

<<<<<<< end read <<<<<<

send >>>>>>

16 CHECK

end send >>>>>>

<<<<<<< read <<<<<<

16 OK CHECK completed

<<<<<<< end read <<<<<<

XCode GM build issues (armv7s arch)

Hi,
I've just downloaded XCode 4.5 GM but my MailCore project does not build. I get those warnings:

Ignoring file libsasl2.a, file was built for archive which is not the architecture being linked (armv7s): 

Same for libmailcore, libcrypto, libssl.

I think all the libs need be changed to build to the "default" architecture $(ARCHS_STANDARD_32_BIT) which is now armv7 and armv7s

In libcrypto, and libssl, I had to add "armv7s" in the "Valid Architectures"

This removes the warnings, and all libs seem to build for armv7 and armv7s but I'm still getting linker errors

fatal error and Unable to checkout.

When try "git submodule update --init" command.

Terminal log.
Submodule 'iOSPorts' (https://github.com/mronge/iOSPorts.git) registered for path 'iOSPorts'
Submodule 'libetpan' (https://github.com/mronge/libetpan.git) registered for path 'libetpan'
Cloning into 'iOSPorts'...
remote: Counting objects: 2024, done.
remote: Compressing objects: 100% (975/975), done.
remote: Total 2024 (delta 1058), reused 1706 (delta 820)
Receiving objects: 100% (2024/2024), 1.19 MiB | 396 KiB/s, done.
Resolving deltas: 100% (1058/1058), done.
fatal: reference is not a tree: ec41248411126096584f0afd34f2b1844f51bca7
Cloning into 'libetpan'...
remote: Counting objects: 1025, done.
remote: Compressing objects: 100% (412/412), done.
remote: Total 1025 (delta 644), reused 969 (delta 597)
Receiving objects: 100% (1025/1025), 1.06 MiB | 559 KiB/s, done.
Resolving deltas: 100% (644/644), done.
Submodule path 'libetpan': checked out 'ed9109b1d4928cc9067fbcf375b3b0f8420b3e9a'
Unable to checkout 'ec41248411126096584f0afd34f2b1844f51bca7' in submodule path 'iOSPorts'

How can i fix it? Help me.

Invalid folder path after encoding in CTCoreFolder

For example list command returns some folder path:
[Gmail]/&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-

This path is an equivalent to Sent folder in Cyrillic.

CTCoreFolder class uses getUTF7String function to initialize mailfolder structure.
But this function returns
[Gmail]/&-BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-
and connection to this path fails, because it is wrong

Why don't you use [NSString UTF8String] instead?

Is it possible to get the progress of send an email with mailcore?

Im using the following method to send an email. Is it possible to get the percentage of email which has been send? I need the progress to feed my progress bar. Thanks in advance!

  • (BOOL)sendMessage:(CTCoreMessage *)message server:(NSString *)server username:(NSString *)username

Can't find MailCore.h file

The build goes well when I build for iOs Simulator or Device but when I try to archive it, it says that it can't find MailCore.h
I have an import <MailCore/MailCore.h> and in the Header Search Path I have like suggested her in the manual ( $(BUILT_PRODUCTS_DIR)/../../include ) but it can't find the header

Package MailCore as a framework?

Is it possible that MailCore could be packaged as a framework and added to a project that way rather than doing the sub-project thing? I'd want a "MailCore.framework" file that could be added to my project.

CTCoreMessage:setBody: causes htmlBody to be filled with the plain text body

CTCoreMessage *message = [CTCoreMessage new];
[message setTo:@"[email protected]];
[message setFrom:[NSSet setWithObject:@"[email protected]"]];
[message setBody:@"Some long body text"];
NSLog(@"Body: %@", message.body);
NSLog(@"HTML Body: %@", message.htmlBody);

We save a copy of this message object in the outbox/local sent message folder of some sort.

When accessing this message object, it becomes misleading that the mail actually had HTML content when it really doesn't.

The issue is that if we trust MailCore to return HTML content while accessing htmlBody, but what it returns is actually plain text, then formatting becomes an issue as line breaks in plain text are ignored by UIWebView.

Also found that if you set htmlBody to nil or @"" to prevent the issue, both body and htmlBody becomes empty.

Cannot run examples on OSX

Compiling the OSX examples leaves us with with the following error

dyld: Library not loaded: /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
  Referenced from: /Users/beebe/Library/Developer/Xcode/DerivedData/InboxLister-fkeccaadxggodjawcojolaopmstw/Build/Products/Debug/MailCore.framework/Versions/A/MailCore
  Reason: image not found
(lldb) 

You can see others having this issue on stackoverflow.

I can build all of the projects, and I can build & run the iOS demo project. I cannot run the OSX projects because they error at runtime.

Stream error in poor network condition cause crashes

In poor network conditions if we try to send or download a attachment file for example greator than 1 mb the libetpan cause the app to crash by producing malloc_error_break. Here is the part of code

The stack Trace is like this

  • (void)fetchPart {
    if (self.fetched == NO) {
    struct mailmime_single_fields *mimeFields = NULL;

    int encoding = MAILMIME_MECHANISM_8BIT;
    mimeFields = mailmime_single_fields_new(mMime->mm_mime_fields, mMime->mm_content_type);
    if (mimeFields != NULL && mimeFields->fld_encoding != NULL)
        encoding = mimeFields->fld_encoding->enc_type;
    
    char *fetchedData;
    size_t fetchedDataLen;
    int r;
    r = mailmessage_fetch_section(mMessage, mMime, &fetchedData, &fetchedDataLen);
    if (r != MAIL_NO_ERROR) {
       //The crash appers to be in this part
            mailmessage_fetch_result_free(mMessage, fetchedData);
            RaiseException(CTMIMEParseError, CTMIMEParseErrorDesc);
    }
    
    size_t current_index = 0;
    char * result;
    size_t result_len;
    r = mailmime_part_parse(fetchedData, fetchedDataLen, &current_index,
                                encoding, &result, &result_len);
    if (r != MAILIMF_NO_ERROR) {
            mailmime_decoded_part_free(result);
            RaiseException(CTMIMEParseError, CTMIMEParseErrorDesc);
    

    }
    NSData *data = [NSData dataWithBytes:result length:result_len];
    mailmessage_fetch_result_free(mMessage, fetchedData);
    mailmime_decoded_part_free(result);
    mailmime_single_fields_free(mimeFields);
    self.data = data;
    self.fetched = YES;
    }
    }

LIBETPAN_EXPORT
int mailmessage_fetch_result_free(mailmessage * msg_info,
char * msg)
{
if (msg_info->msg_driver->msg_fetch_result_free == NULL)
return MAIL_ERROR_NOT_IMPLEMENTED;

msg_info->msg_driver->msg_fetch_result_free(msg_info, msg); //This cause the app to crash. This is the last point in gdb stack trace

return MAIL_NO_ERROR;
}

Exposing the IMAP APPEND command

Hello,

I am attaching a small patch with which the IMAP APPEND command is exposed through the CTCoreFolder class.

diff --git a/Source/CTCoreFolder.h b/Source/CTCoreFolder.h
index 623212e..e3a7705 100644
--- a/Source/CTCoreFolder.h
+++ b/Source/CTCoreFolder.h
@@ -185,6 +185,12 @@
 - (BOOL)unsubscribe;

 /**
+ Exposes the IMAP APPEND command, see the IMAP RFC 4549.
+ @return Return YES on success, NO on error. Call method lastError to get error if one occurred
+ */
+- (BOOL) appendMessage: (CTCoreMessage *) msg;
+
+/**
  Retrieves the message flags. You must AND/OR using the defines constants.
  Here is a list of message flags:
  CTFlagNew, CTFlagSeen, CTFlagFlagged, CTFlagDeleted,
diff --git a/Source/CTCoreFolder.m b/Source/CTCoreFolder.m
index ed489ce..d6db35d 100644
--- a/Source/CTCoreFolder.m
+++ b/Source/CTCoreFolder.m
@@ -212,6 +212,19 @@ int uid_list_to_env_list(clist * fetch_result, struct mailmessage_list ** result
     return YES;
 }

+- (BOOL) appendMessage: (CTCoreMessage *) msg
+{
+    int err = MAILIMAP_NO_ERROR;
+    NSString *msgStr = [msg render];
+    if (![self connect])
+        return NO;
+    err = mailsession_append_message ([self folderSession],
+                                      [msgStr cStringUsingEncoding: NSUTF8StringEncoding],
+                                      [msgStr lengthOfBytesUsingEncoding: NSUTF8StringEncoding]);
+    if (MAILIMAP_NO_ERROR != err)
+        self.lastError = MailCoreCreateErrorFromIMAPCode (err);
+    return MAILIMAP_NO_ERROR == err;
+}

 - (struct mailfolder *)folderStruct {
     return myFolder;

CocoaPod?

Any thoughts on enabling installation via CocoaPods. Happy to help but want to make sure you're interested first.

"[GMail]" folder causes exception

Connecting to Google's IMAP and going through the folder (see #2) ...getting the total message counts throws an exception for the "[GMail]" folder.

I assume this one is special as it's the parent of some other folders. Maybe just something to check in the metadata somewhere ...but haven't found that yet.

SMTP over SSL seems not to work

I can not connecto to the google-smtp (smtp.gmail.com) on port 465 (as they describe).
The server, port and account inof is correct beacue it works with other mail-clients.

is this a bug or is this a non supported feature?

Gabriel

Error 9 when getting totalMessageCount

I just changed the InboxLister example like this

NSSet *folders = [myAccount allFolders];
NSEnumerator *objEnum = [folders objectEnumerator];
NSString *folderName;
while((folderName = [objEnum nextObject])) {
    if (![@"[Gmail]" isEqualToString: folderName]) {
        CTCoreFolder *folder = [myAccount folderWithPath:folderName];
        NSLog(@"%@: %d", folderName, [folder totalMessageCount]);            
    }
}

and after a couple of folders it throws an exception with error 9.
This is connecting to imap.gmail.com with TLS port 993

Haven't had the time to dig deeper yet.

32bit build fails on MacOS 10.6

When I tried to build MailCore (for Mac, not iOS) on my Mac (MacOs 10.6.8, Xcode 4.2) as 32bit version, the build fails with the following error message:

.../MailCore/Source/CTCoreMessage.m:57:43: error: synthesized property 'parentFolder' must either be named the same as a compatible ivar or must explicitly name an ivar [3]
 @synthesize mime=myParsedMIME, lastError, parentFolder;

Interestingly, building a 64bit version works fine. But since I need a 32/64bit version, that doesn't really help me.
Any ideas?

Calling rfc822 after messageWithUID fails

The reason is that unlike the other methods like messagesFromSequenceNumber:, messageWithUID doesn't fill in a sequenceNumber for the message which rfc822 requires for doing its fetch.

Default deployment target leads to crash on iOS 5 when compiling under Xcode 4.5

The deployment target of MailCore and its submodules are unset, leaving it to Xcode to set based on the latest available SDK bundled with it.

The result is that when compiling a project with Xcode 4.5, the deployment target of MailCore and its submodules default to iOS 6.0.

This means that apps compiled with Xcode 4.5 will crash when running under iOS 5 or earlier, even though MailCore supports iOS 5 or earlier.

The workaround is to manually go through the Build Settings of MailCore and its associated submodules, and changing the iOS Deployment Target to 5.0 (or earlier).

Perhaps MailCore should consider setting the deployment target to its minimum supported OS.

Memory leaks

Hi,
I see that there are some memory leaks if I just use the sample code from the Gettings Started.

Screenshot

In the render method, the mailmime returned from buildMIMEStruct is never freed.

Screenshot

Why do not build contentId of CTMIME_SinglePart?

Here im trying to embed an image in my email. I need to send the contentId as described here http://stackoverflow.com/questions/4312687/how-to-embed-images-in-email , but unfortunately I find the mailcore do not build the contentId in the following method:

CTMIME_SinglePart.m
...

  • (struct mailmime *)buildMIMEStruct {
    struct mailmime_fields *mime_fields;
    struct mailmime *mime_sub;
    struct mailmime_content *content;
    int r;

    if (mFilename) {
    mime_fields = mailmime_fields_new_filename( MAILMIME_DISPOSITION_TYPE_ATTACHMENT,
    (char *)[mFilename cStringUsingEncoding:NSUTF8StringEncoding],
    MAILMIME_MECHANISM_BASE64 );
    } else {
    mime_fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_BASE64);
    }
    content = mailmime_content_new_with_str([self.contentType cStringUsingEncoding:NSUTF8StringEncoding]);
    mime_sub = mailmime_new_empty(content, mime_fields);

    // Add Data
    r = mailmime_set_body_text(mime_sub, (char *)[self.data bytes], [self.data length]);
    return mime_sub;
    }

...

Is there anything i missed? Thanks for any help!

messageObjectsFromIndex gives unexpected results

Do I just have wrong expectations?

I have cases where the number of messages returned does not match the index range:

NSSet *messages1 = [folder messageObjectsFromIndex:0 toIndex:100-1];
NSSet *messages2 = [folder messageObjectsFromIndex:100 toIndex:200-1];
NSSet *messages3 = [folder messageObjectsFromIndex:200 toIndex:300-1];
[messages1 count] == 156
[messages1 count] == 100
[messages1 count] == 55

Here are a couple of examples:

 folder1:
  0..35: 2
 folder2:
  0..100: 157
  100..200: 100
  200..255: 55
 folder3:
  0..100: 3499
  100..200: 100
  200..300: 100
  300..400: 100
  400..500: 100

What's going on there?
Seems like the docs are not up-to-date.

/*
    Implementation is in alpha.
*/
//TODO Document Me!
- (NSSet *)messageObjectsFromIndex:(unsigned int)start toIndex:(unsigned int)end;

/*!
    @abstract   This will return the message from this folder with the UID that was passed in. If the message
                can't be found, nil is returned
    @param      uid The uid as an NSString for the message to retrieve.
    @result     A CTMessage object is returned which can be used to get further information and perform operations
                on the message.
*/

sendMessage timeout for poor connectivity?

We are noticing some interesting problems with poor network connectivity when trying to send an SMTP Message. It appears we are getting locked up while trying to send a message, which had us wondering if there is any sort of timeout enabled?

Our code is always checking canConnectToServer before calling sendMessage, and despite getting a green flag, still has issues sending a message.

Bug in sending mail through bcc

When sending an email with receipts as following
to: personA
cc: personB
bcc :personC

All the three person will get the email. And all the received emails will display personC in the receipts area. As we know the bcc contacts should not be displayed. Why could this happen? I correctly set the CTCoreMessage with to, cc and bcc. Is this a bug of MailCore Framework? Or is there something i missed?

Thanks in advance!

Memory Leak in CTCoreAccount's connectToServer

Instruments reports a leak when executing the following code:

CTCoreAccount *_account = [[CTCoreAccount alloc] init];
[_account
 connectToServer: @"imap.gmail.com"
 port: 993
 connectionType: CONNECTION_TYPE_TLS
 authType: IMAP_AUTH_TYPE_PLAIN
 login: @"[email protected]"
 password: @"mypassword"
 ];

[_account disconnect];
[_account release];

This issue is 100% reproducible:

  • create a new Cocoa application in Xcode
  • paste the code in the applicationDidFinishLaunching: implementation of your AppDelegate
  • run the application with instruments (standard Leaks template)
  • wait a few seconds after the application has fully opened

Get Message Body

Hi,
I'm trying to get the body of a Mail but it's always empty.
My code is
CTCore *folder = [[CTCorefolder alloc] initWithPath:@"INBOX" inAccount:account];
for( CTCoreMessage *msg in [folder messageObjectsFromIndex : 0 toIndex:10] ){
if([msg.subject isEqualToString:@"test")]){
// no pb here, it find the good Mail
NSLog(@"Message Body length : %d", msg.body.length);
// here the length is 0 and the body is : ""
}
}
There are other way to get the body, like "msg.HtmlBody" but it is empty too.
However on firefox I can see the body which isn't empty.
How should I do ?

Large Attachments

i"m having a issue fetching large attachments (~8-10mb+). Upon fetching the full attachment, a "Copy command error" is returned. The log shows it connects fine, downloads a small portion of the attachment, and then stops. Has anything experienced a issue like this?

Get CTMIME_SinglePart data

Hi,
I have a problem to get some NSData stored in a CTMIME_SinglePart.

The mail has been sent like this : (data is NSData and msg is CTCoreMessage)

CTMIME_SinglePart *part = [CTMIME_SinglePart mimeSinglePartWithData:data];
part.contentType = @"application/macbinary";
CTMIME_MultiPart *multi = [CTMIME_MultiPart mimeMultiPart];
[multi addMIMEPart:part];
CTMIME_MessagePart *message = [CTMIME_MessagePart mimeMessagePartWithContent:multi];
msg.mime=message;

And I try to read it like this :

   CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];

    CTMIME_Enumerator *Ennum = [mime mimeEnumerator];
    NSArray *allOb = [Ennum allObjects];

    CTMIME_MessagePart *msgpart = [allOb objectAtIndex:0];

    CTMIME_MultiPart *multi = [[CTMIME_MultiPart alloc]init ];

        if ([[msgpart content] isKindOfClass:[CTMIME_MultiPart class]]) {
                multi = [msgpart content]; 
        }

        if ([[[multi content] objectAtIndex:s] isKindOfClass:[CTMIME_SinglePart class]]) {
                CTMIME_SinglePart *single = [[CTMIME_SinglePart alloc]init ];
                single = [[multi content]objectAtIndex:s];

                NSLog(@"length : %@", [[single data]length]); // here length is null  --> This is my problem 
        }

Data is always null and [single attached] too. What do you think about it ?

POP3 support?

Is it possible to read POP3 accounts with MailCore? If yes - how?

Header Search Paths

I’m pretty good with Objective-C, but not so good with Xcode, so forgive me if I’m missing something stupid…

If I clone the MailCore repo and follow the instructions to add it to my project, MailCore builds fine, but my project fails at the end claiming that it can’t locate MailCore/MailCore.h. If I add both MailCore/Source and MailCore/libetpan/build-mac/include to Header Search Paths, it will build (assuming I also change the line to #import "MailCore.h").

The instructions used to include adding ../MailCore/include to Header Search Paths. I’m guessing 704741e was supposed to make that unnecessary? But for me, it isn’t. For what it’s worth, I had to add the entry for libtpan before the recent commit as well.

Thanks.

ContentType not correctly parsed

Hi,
it looks like the Content-Type header line is parsed only by the "main" type (e.g. "text") and "subtype" (e.g. "plain") but not the rest.

CTCoreMessage *msg = [[CTCoreMessage alloc] initWithString:@"Subject: MySubject\n"
            "Content-Type: text/plain; charset=us-ascii"];
msg.fetchBodyStructure;

NSLog(@"ContentType: %@", [(CTMIME_TextPart*)msg.mime.content contentType]);

The resulting Content-Type is "text/plain" and the charset is dropped.

Rendering a CTCoreMessage more than once causes segfault.

The call to mailmime_free introduced in the changeset 4a7a6f8 causes a segfault when render is called on the same CTCoreMessage more than once. The problem seems to be that the call to free destroys the myFields of CTMIME_MessagePart. The sequence of instructions within CTMIME render method is

  1. [self buildMIMEStruct]
  2. mailmime_set_imf_fields(mime, myFields) which does
    build_info->mm_data.mm_message.mm_fields = mm_fields
    ....
  3. mailmime_free (mime) which frees
    mailimf_fields_free(mime->mm_data.mm_message.mm_fields)

I set the fields to NULL as shown bellow before the call to free, and the issue went away, however i am not sure whether that is an acceptable solution.

diff --git a/Source/CTMIME.m b/Source/CTMIME.m
index 9e2ed9b..1a1a4d6 100644
--- a/Source/CTMIME.m
+++ b/Source/CTMIME.m
@@ -112,6 +112,7 @@
     resultStr = [[NSString alloc] initWithBytes:str->str length:str->len
                     encoding:NSUTF8StringEncoding];
     mmap_string_free(str);
+    mime->mm_data.mm_message.mm_fields = NULL;
     mailmime_free(mime);
     return [resultStr autorelease];
 }

No concurrency support?

Is it a limitation of MailCore or IMAP, that all requests to server must be done in a single queue?
If I have more than one concurrent requests, it will either crash the app or returns nothing. Maybe I missed out on some settings to enable concurrency?

CTCoreAccount:read questions

I have been trying to use CTCoreAccount:read. It always seems to timeout and return NULL and the lastError on the account is also NULL. There is not much information on how it should be used.

Has anyone had any luck with it?

"Parse Error" during CTCoreFolder#connectToServer

Hi,
my ldap connection works fine when I'm connected to my local network. When I connect via VPN to my local network, I'm not able to connect to my imap server anymore.

In the CTCoreFolder#connectToServer method the call to "mailstorage_connect" produces a "Parse Error".

If I debug the code, the libetpan call to 'mail_tcp_connect_with_local_address' fails:

    fd = mail_tcp_connect_with_local_address(servername, port,
        local_address, local_port);
    if (fd == -1) {
      res = MAIL_ERROR_CONNECT;
      goto err;
    }

The imap server itself is accessible and the Apple's Mail client is able to list the email.

What could be the reason? How could I debug this problem more? Using MailCoreEnableLogging() does not print anything.

cheers

CTCoreFolder needs a reconnect method

Currently when accessing totalMessageCount, it returns a cached value based on when the folder was last connected. There needs to be a reconnect method, so that the total message count can be updated correctly.

Problem with fetching audio attachments

I tried to fetch an audio file with extension "amr" using attachments method in CTCoreMessage but in vein. When I debug the code, I see it's reading "Content-Type: audio/amr" from the mail but when it reaches this block:
if (singlePart.attached) {
CTBareAttachment *attach = [[CTBareAttachment alloc]
initWithMIMESinglePart:singlePart];
[attachments addObject:attach];
[attach release];
}

It evaluates "singlePart.attached" as false, then returns 0 objects for attachments. Do you think it's related to audio encoding? what is the proper case to handle audio extensions?

Invalid username or password

When I try to connect to imap with invalid password, system returns right lastError 'Invalid username or password', but than application fails

LIBETPAN_EXPORT
int mailimap_list(mailimap * session, const char * mb,
const char * list_mb, clist ** result)
{
struct mailimap_response * response;
int r;
int error_code;

if ((session->imap_state != MAILIMAP_STATE_AUTHENTICATED) && <-- EXC_BAD_ACCESS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.