Closed Pankaj03 closed 10 years ago
Hm, are you sure that it's not just a Heisenbug? Removing the prebuilts file just affects the scripting mechanism and Travis.
@CodaFi then how is it help me, if my application is on production mode?
What happens when you use the script get-prebuilt.sh in scripts/ ? Does it show the same issue? If it's the case, could you let me know which command fail?
@dinhviethoa Fetching mails command gives "Unable to parse response from server." error.
Does it happen when you build or when you run the code that is built? Please, give more details about your issue. I don't understand it. Thanks!
@dinhviethoa I am using ARC in my application, but in MailCore2 project NO ARC. The problem arises when i run the code for "Fetching Mails from server".
Thanks!
Could you show?
I don't know what "Fetching Mails from server" means for your app.
Could you show the data?
Hoa V. Dinh
On Sunday, October 27, 2013 at 11:53 PM, Pankaj wrote:
See the following logs:
2013-10-28 12:18:42.549 Mail App[4528:a207] ConnectionLogger event logged: 1 withData:
2013-10-28 12:18:42.949 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:42.985 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:43.871 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:44.078 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:47.456 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:47.661 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:48.285 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:48.479 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:48.491 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:48.904 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:48.916 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:48.928 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:49.093 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:49.298 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:49.502 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:49.510 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:49.708 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:49.723 Mail App[4528:a207] ConnectionLogger event logged: 0 withData:
2013-10-28 12:18:49.728 Mail App[4528:a207] ConnectionLogger event logged: 3 withData:
2013-10-28 12:18:49.731 Mail App[4528:60b] error in imapMessagesFetchOp : Error Domain=MCOErrorDomain Code=3 "Unable to parse response from server." UserInfo=0x1920d0f0 {NSLocalizedDescription=Unable to parse response from server.}— Reply to this email directly or view it on GitHub (https://github.com/MailCore/mailcore2/issues/433#issuecomment-27192188).
Could you convert data to string? using UTF8 encoding.
It will be helpful.
Hoa V. DINH
On Monday, October 28, 2013 at 10:04 PM, Pankaj wrote:
@dinhviethoa (https://github.com/dinhviethoa)
See the following code and attached logs of error: self.imapSession = [[MCOIMAPSession alloc] init]; self.imapSession.hostname = servrName; self.imapSession.port = port; self.imapSession.username = UName; self.imapSession.password = pwd; if ([securityType isEqualToString:@"SSL"]) { self.imapSession.connectionType = MCOConnectionTypeTLS; } else{ self.imapSession.connectionType = MCOConnectionTypeClear; } self.imapSession.authType = MCOIMAPCapabilityAuthPlain; self.imapCheckOp = [self.imapSession checkAccountOperation]; [self.imapSession setConnectionLogger:^(void * connectionID, MCOConnectionLogType type, NSData * data) { NSLog(@"ConnectionLogger event logged: %i withData: %@", type, data); }]; [self.imapCheckOp start:^(NSError error) { if (error == nil) { [self loadLastNNewMessages]; } else { NSLog(@"error loading account: %@", error); NSString str = [self stringBetweenString:@"\"" andString:@"\"" ofString:[NSString stringWithFormat:@"%@",error]]; } }]; } else{ }
For loadLastNNewMessages:
- (void)loadLastNNewMessages{ MCOIMAPMessagesRequestKind requestKind = (MCOIMAPMessagesRequestKind) (MCOIMAPMessagesRequestKindFullHeaders | MCOIMAPMessagesRequestKindStructure | MCOIMAPMessagesRequestKindInternalDate | MCOIMAPMessagesRequestKindHeaderSubject | MCOIMAPMessagesRequestKindFlags | MCOIMAPMessagesRequestKindUid); NSString _inboxFolder = @"INBOX"; MCOIMAPFolderInfoOperation inboxFolderInfo = [self.imapSession folderInfoOperation:inboxFolder]; [inboxFolderInfo start:^(NSError error, MCOIMAPFolderInfo info) { int start = msgLastID+1; MCOIndexSet uids = [MCOIndexSet indexSetWithRange:MCORangeMake(start, UINT64MAX)]; MCOIMAPFetchMessagesOperation *fetchOperation = [self.imapSession fetchMessagesByUIDOperationWithFolder:inboxFolder requestKind:requestKind uids:uids]; void(^fetchHandler)(NSError,NSArray,MCOIndexSet) = ^(NSError error, NSArray fetchedMessages, MCOIndexSet vanishedMessages) { if (error) { NSString str = [self stringBetweenString:@"\"" andString:@"\"" ofString:[NSString stringWithFormat:@"%@",error]]; return; } if ([fetchedMessages count] > 0) { NSSortDescriptor sort = [NSSortDescriptor sortDescriptorWithKey:@"header.date" ascending:YES]; NSArray sortedArr = [fetchedMessages sortedArrayUsingDescriptors:@[sort]]; NSMutableArray *combinedMessages = [NSMutableArray arrayWithArray:sortedArr]; [[AppDelegate shared] performSelectorInBackground:@selector(messagesLoad:) withObject:combinedMessages]; } else{ appObj.isDone = @"Yes"; } }; [fetchOperation start:fetchHandler]; }];
} Please see the attached logs. Thanks!— Reply to this email directly or view it on GitHub (https://github.com/MailCore/mailcore2/issues/433#issuecomment-27278911).
I think I lost your comments in this issue. @Pankaj03 Could you paste again the data in a gist. I'd like to investigate what's going. Thanks! If you have an account or a server where it can be reproduce, it will also be helpful.
@dinhviethoa Yes, sure! If you want, i can forward that particular mail, which i unable to parse. Please provide the email id where i can forward that mail If you want to test it, following is the credentials: Server: mail.data.in Username: test@data.in Password: Tester@123
Please find the following error logs as:
2013-11-26 14:32:41.450 MailApp Mail[6015:640b] ConnectionLogger event logged: 0 withData: * OK IMAP4 Service Ready.
2013-11-26 14:32:41.455 MailApp Mail[6015:640b] ConnectionLogger event logged: 1 withData: 1 CAPABILITY
2013-11-26 14:32:41.461 MailApp Mail[6015:640b] ConnectionLogger event logged: 0 withData: * CAPABILITY IMAP4 IMAP4rev1 LITERAL+
1 OK Completed
2013-11-26 14:32:41.461 MailApp Mail[6015:640b] ConnectionLogger event logged: 2 withData: 2 LOGIN “****@dil.in" ***********
2013-11-26 14:32:41.540 MailApp Mail[6015:640b] ConnectionLogger event logged: 0 withData: 2 OK Login Completed.
2013-11-26 14:32:41.540 MailApp Mail[6015:640b] ConnectionLogger event logged: 1 withData: 3 CAPABILITY
2013-11-26 14:32:41.594 MailApp Mail[6015:640b] ConnectionLogger event logged: 0 withData: * CAPABILITY IMAP4 IMAP4rev1 LITERAL+
3 OK Completed
2013-11-26 14:32:41.594 MailApp Mail[6015:640b] ConnectionLogger event logged: 1 withData: 4 LIST "" ""
2013-11-26 14:32:41.663 MailApp Mail[6015:640b] ConnectionLogger event logged: 0 withData: * LIST (\NoSelect) "/" ""
4 OK LIST Completed.
2013-11-26 14:32:41.873 MailApp Mail[6015:640b] ConnectionLogger event logged: 1 withData: 5 SELECT INBOX
2013-11-26 14:32:41.930 MailApp Mail[6015:640b] ConnectionLogger event logged: 0 withData: * 214 EXISTS
* 0 RECENT
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen)] Permanent flags
* OK [UIDVALIDITY 1] UIDVALIDITY value
5 OK [READ-WRITE] SELECT Completed.
2013-11-26 14:32:41.932 MailApp Mail[6015:640b] ConnectionLogger event logged: 1 withData: 6 FETCH 205:214 (UID FLAGS BODY.PEEK[HEADER.FIELDS (Date Subject From Sender Reply-To To Cc Message-ID References In-Reply-To)] BODYSTRUCTURE INTERNALDATE)
2013-11-26 14:32:42.030 MailApp Mail[6015:640b] ConnectionLogger event logged: 0 withData: * 205 FETCH (UID 31449369 FLAGS (\SEEN) INTERNALDATE "16-Nov-2013 17:31:29 +0000" BODYSTRUCTURE ("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2181 41 NIL NIL NIL) BODY[HEADER.FIELDS (Date Subject From Sender Reply-To To Cc Message-ID References In-Reply-To)] {140}
Subject: Unvalidate Sender For Sat, 16 Nov 2013
To: *********@dil.in
From: internet@dil.in
Date: Sat, 16 Nov 2013 23:01:29 +0530
)
2013-11-26 14:32:42.049 MailApp Mail[6015:640b] ConnectionLogger event logged: 3 withData: 205 FETCH (UID 31449369 FLAGS (\SEEN) INTERNALDATE "16-Nov-2013 17:31:29 +0000" BODYSTRUCTURE ("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2181 41 NIL NIL NIL) BODY[HEADER.FIELDS (Date Subject From Sender Reply-To To Cc Message-ID References In-Reply-To)] {140}
2013-11-26 14:32:42.050 MailApp Mail[6015:70b] error in imapMessagesFetchOp : Error Domain=MCOErrorDomain Code=3 "Unable to parse response from server." UserInfo=0xc6cb160 {NSLocalizedDescription=Unable to parse response from server.}
@dinhviethoa Please find the following attachment regarding "Unable to parse response" error:
The attachment shows the Mail Body in which i got the error "Unable to parse response from server".
Thanks!
Hi, did you remove this message from this mailbox? It doesn't show. I only see the message with the subject "Fw: Unvalidate sender ...". I can't see the original one.
@dinhviethoa Hello.
See the file at following url: http://pastebin.com/H0KZtrAT
I had paste the original content of mail of which i am getting error to parse.
Thanks!
The issue might also be interaction between this mail and the server.
Could you have it again on the server?
Hoa V. DINH
On Friday, November 29, 2013 at 10:21 PM, Pankaj wrote:
@dinhviethoa (https://github.com/dinhviethoa) Hello. See the file at following url: http://pastebin.com/H0KZtrAT
I had paste the original content of mail of which i am getting error to parse. Thanks!— Reply to this email directly or view it on GitHub (https://github.com/MailCore/mailcore2/issues/433#issuecomment-29546819).
@dinhviethoa Actually the mail is on live server. When i forward this mail, its encoding changes to quoted-printable and no parsing error. So i need some time to transfer this mail to the account which i had shared with you.
Thanks!
Let me know when it's available. Thanks!
@dinhviethoa I 'll replied you in 10-15mins, after discussing with server peoples.
Thanks!
@dinhviethoa Hi. Now, you can check with following account:
Server: mail.data.in Username: test@data.in Password: Tester@123
Thanks!
@dinhviethoa Please do help me to find out what is wrong with this mail from which i am getting error "Unable to parse response from server.", as my application is ready for production or distribution but i am stuck at that point only.
Thanks!
@dinhviethoa Hello! How are you?
I find the location and function where i am getting the error "Unable to parse response from server", please see below:
it is in libetpan -->src --> low-level --> imap --> mailimap_keywords.c:
int mailimap_space_parse(mailstream * fd, MMAPString * buffer,
size_t * indx)
{
#ifdef UNSTRICT_SYNTAX
/* can accept unstrict syntax */
size_t cur_token;
cur_token = * indx;
while (is_space_or_tab(* (buffer->str + cur_token)))
{
cur_token ++;
}
if (cur_token == * indx){
/*
This is the point where it fails to parse and gives the error
*/
return MAILIMAP_ERROR_PARSE;
}
* indx = cur_token;
return MAILIMAP_NO_ERROR;
#else
return mailimap_char_parse(fd, buffer, indx, ' ');
#endif
}
Please do help.
Thanks!
Hi @Pankaj03, Thanks for the investigation. Could you let me know what's the call stack? It might be expected that this function returns a parse error.
@dinhviethoa Yes sure. Please find below link:
@dinhviethoa Hello! Have you look at my problem? Will you please help me on a point from where the imap command generated and i get the response from server?
Thanks!
@dinhviethoa Hello!
Have you look at my problem??? As it is very urgent.
Thanks!
Hi @Pankaj03,
Please keep in mind that it's an open source project that I work on my free time. I'll try to have a look within this week.
Quickly: I think that the IMAP server is not conformant when sending the parsed bodystructure. If you have any control on the IMAP server, you should check it.
@dinhviethoa Ok Thanks!.
Sorry for disturbing you.
Here's my analyze:
Here's one part of the response of the server:
17 FETCH (UID 31860878 FLAGS () INTERNALDATE "30-Nov-2013 06:47:18 +0000" BODYSTRUCTURE ("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2667 49 NIL NIL NIL) ENVELOPE ("Fri, 15 Nov 2013 23:01:42 +0530" "Unvalidate Sender For Fri, 15 Nov 2013" ((NIL NIL "internet" "dil.in")) ((NIL NIL "internet" "dil.in")) ((NIL NIL "internet" "dil.in")) ((NIL NIL "pankajasudani" "dil.in")) NIL NIL NIL NIL) BODY[HEADER.FIELDS (References Subject)] {52}
On this server, BODYSTRUCTURE is wrong:
("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2667 49 NIL NIL NIL)
There's an extra "7BIT" after "HTML".
To workaround it, you must not fetch the body structure of the message and instead fetch the whole content of the message and parse it.
Cheers.
@dinhviethoa Hello! Thank you so much for your precious time. You are a life saver!!
Is there any alternate solution for this or how can i call (method) for whole content of the message ? Can i handle at my side?
Thanks for your kind support!
Please, have a look at the APIs. Session provides a way to get the content of the whole message.
@dinhviethoa Hello! I want to get the 10 most recent messages only on first load. So, can you please guide me, how can i achieve it with no error?
Thanks!
You can fetch by message number using MCOIMAPSession's API.
@CodaFi Thanks for reply! I need the whole content of message without passing the "requestKind:MCOIMAPMessagesRequestKind". As i have problem in "MCOIMAPMessagesRequestKindStructure".
If you have the message structure, you can enumerate each message from the request and get it's contents. They are attachments, not an actual part of the message most of the time, but you can also request the full content of each message if you want to using MCOIMAPSession again.
@CodaFi Thanks! But how can i request the full content of each message using MCOIMAPSession. Please guide me.
@dinhviethoa Can you please tell me, where is the code in libetpan/mailcore in which there is parsing of following command:
BODYSTRUCTURE ("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2667 49 NIL NIL NIL)
From this command:
17 FETCH (UID 31860878 FLAGS () INTERNALDATE "30-Nov-2013 06:47:18 +0000" BODYSTRUCTURE ("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2667 49 NIL NIL NIL) ENVELOPE ("Fri, 15 Nov 2013 23:01:42 +0530" "Unvalidate Sender For Fri, 15 Nov 2013" ((NIL NIL "internet" "dil.in")) ((NIL NIL "internet" "dil.in")) ((NIL NIL "internet" "dil.in")) ((NIL NIL "pankajasudani" "dil.in")) NIL NIL NIL NIL) BODY[HEADER.FIELDS (References Subject)] {52}
Take a look at mailimap_parser.c in libetpan.
Matt Ronge http://astro-hq.com iOS and Mac Apps
On Dec 17, 2013, at 3:18 AM, Pankaj notifications@github.com wrote:
@dinhviethoa Can you please tell me, where is the code in libetpan/mailcore in which the parsing of following command:
BODYSTRUCTURE ("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2667 49 NIL NIL NIL) From this command:
17 FETCH (UID 31860878 FLAGS () INTERNALDATE "30-Nov-2013 06:47:18 +0000" BODYSTRUCTURE ("TEXT" "HTML" "7BIT" NIL NIL NIL "7BIT" 2667 49 NIL NIL NIL) ENVELOPE ("Fri, 15 Nov 2013 23:01:42 +0530" "Unvalidate Sender For Fri, 15 Nov 2013" ((NIL NIL "internet" "dil.in")) ((NIL NIL "internet" "dil.in")) ((NIL NIL "internet" "dil.in")) ((NIL NIL "pankajasudani" "dil.in")) NIL NIL NIL NIL) BODY[HEADER.FIELDS (References Subject)] {52} — Reply to this email directly or view it on GitHub.
@dinhviethoa @mronge Thanks! I got a method, but unable to solve it. Please help me as i am beginner in programming. See the following code snippet:
static int
mailimap_msg_att_bodystructure_parse(mailstream * fd, MMAPString * buffer,
size_t * indx,
struct mailimap_body ** result,
size_t progr_rate,
progress_function * progr_fun)
{
struct mailimap_body * body;
size_t cur_token;
int r;
cur_token = * indx;
r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token,
"BODY");
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token,
"STRUCTURE");
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_space_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR)
return r;
r = mailimap_body_parse(fd, buffer, &cur_token, &body,
progr_rate, progr_fun);
if (r != MAILIMAP_NO_ERROR)
return r;
* result = body;
* indx = cur_token;
return MAILIMAP_NO_ERROR;
}
Don't try to fix it in libetpan. It would break for other servers. Please, have a look the examples. They should help.
@dinhviethoa Thanks! But i want to try it locally in my code only, would it help me. Or instead of fetching BODYSTRUCTURE, how can i fetch the whole content of message.
You can use MCOIMAPFetchContentOperation
for the whole message:
MCOIMAPFetchContentOperation *request = [self.session fetchMessageByUIDOperationWithFolder:folder.path uid:uid];
[request start:^(NSError *error, NSData *data) {
}];
If you want the body, you fetch body structure, then loop through the message parts firing off calls to -[MCOIMAPSession fetchMessageAttachmentByUIDOperationWithFolder:uid:partID:encoding:(urgent:)]
as needed.
@CodaFi That code will return the body of message of an individual messageID, but i need the recent 10 messages with attachment count.
So what about this isn't working, then? Is the attachments array on each message nil?
@CodaFi How can i pass the message uid instead i need to pass multiple uids. As i am using:
[self.imapSession fetchMessagesByNumberOperationWithFolder:inboxFolder
requestKind:requestKind
numbers:
[MCOIndexSet indexSetWithRange:fetchRange]];
The problem is that you're assuming that the body of a message is just one contiguous chunk that you can fetch. They're attachments, and need to be fetched like attachments. When you fetch the messages by number, you have to enumerate all the parts and fetch each one by ID for each message.
@CodaFi Thanks!
@dinhviethoa @CodaFi Hello,
Can you please tell me, how can i get the MessageUID that contains attachment or how can i find the attachment count (without passing BODYSTRUCTURE RequestKind)?
Thanks!
Why without passing that flag? If your server is broken and can't handle the request correctly, report it to the people who own it so they can fix it.
@CodaFi If they are refusing to correct it, then what should i do on my side? As it is working perfectly for other email clients.
Thanks!
Then there is nothing more you can do with them, sorry. You've done the most you could assuming you provided them a detailed description of the problem. Maybe you could try writing your own parser, but that would have to be at the LibEtPan level, not the MailCore level.
Hello
i am getting error : "Unable to parse response from server."
But when i remove following file: scripts/prebuilt.lists
it is working fine.
Everytime i have to remove this file and buil again?
Please do help.