나는 libetpan과 함께 과거에 작업 중이었고 문제없이 pop3 서버에 연결 했으므로 아직 작동하는지 확인했습니다. 여기에서 코드 (https://github.com/dinhviethoa/libetpan/blob/master/tests/pop-sample.c)를 사용하고 iOS 용으로 조정했습니다.
사용하는 경우 많은 경고가 표시되고 첫 번째 메시지를 가져온 후에 응용 프로그램이 충돌하지만 연결이 작동합니다 (물론 전자 메일 로그인과 암호를 입력해야합니다).
저는 libetpan이 좋은 해결책이라고 말하고 있지 않습니다. 메일 지원이있는 앱을 개발할 때도 IMAP 용 메일 코어를 사용하고 결국 POP3 지원을 중단했습니다. 그러나 옵션에서 실행하면 유용 할 수 있습니다.
static void check_error(int r, char * msg)
{
if (r == MAILPOP3_NO_ERROR)
return;
fprintf(stderr, "%s\n", msg);
exit(EXIT_FAILURE);
}
-(IBAction)testButtonClick:(id)sender
{
mailpop3 * pop3;
int r;
carray * list;
unsigned int i;
// if (argc < 3) {
// fprintf(stderr, "syntax: pop-sample [gmail-email-address] [gmail- password]\n");
// exit(EXIT_FAILURE);
// }
mkdir("download", 0700);
pop3 = mailpop3_new(0, NULL);
r = mailpop3_ssl_connect(pop3, "pop.gmail.com", 995);
check_error(r, "connect failed");
r = mailpop3_user(pop3, @"mail login".cString);
check_error(r, "user failed");
r = mailpop3_pass(pop3, @"mail password".cString);
check_error(r, "pass failed");
r = mailpop3_list(pop3, &list);
check_error(r, "list failed");
NSLog(@"carray_count(list_: %d", carray_count(list));
for(i = 0 ; i < carray_count(list) ; i ++) {
struct mailpop3_msg_info * info;
char * msg_content;
size_t msg_size;
FILE * f;
char filename[512];
struct stat stat_info;
info = (mailpop3_msg_info *) carray_get(list, i);
if (info->msg_uidl == NULL) {
continue;
}
snprintf(filename, sizeof(filename), "download/%s.eml", info->msg_uidl);
r = stat(filename, &stat_info);
if (r == 0) {
printf("already fetched %u %s\n", info->msg_index, info->msg_uidl);
continue;
}
if(msg_content != NULL)
NSLog(@"msg_content: %@", [NSString stringWithUTF8String:msg_content]);
r = mailpop3_retr(pop3, info->msg_index, &msg_content, &msg_size);
check_error(r, "get failed");
// f = fopen(filename, "w");
// fwrite(msg_content, 1, msg_size, f);
// fclose(f);
// mailpop3_retr_free(msg_content);
if (info->msg_uidl != NULL) {
printf("fetched %u %s\n", info->msg_index, info->msg_uidl);
}
else {
printf("fetched %u\n", info->msg_index);
}
}
mailpop3_quit(pop3);
mailpop3_free(pop3);
// exit(EXIT_SUCCESS);
}
하지만 불행히도 여기 https://github.com/miyabichan/OCMail/issues/1 언급 한 문제가 나를 위해 진짜 문제는 ... 그것은 작동 가져올 수 없습니다 :/ – swalkner
내 편집 위를 참조 도움이 되었길 바래요! – FeifanZ
좋아, 나는 .a 파일을 만들 수 있었다. 하지만 테스트 프로젝트로 드래그하면 예를 들어 파일을 가져올 수 없습니다. '#import "MailServer.h"-'file not found' – swalkner