2010-08-09 2 views
0

아이폰 애플 리케이션에 사용하기 위해 어느 누구도 객관적인 - C smtp 라이브러리를 알고.아이폰 smtp 클라이언트 라이브러리

나는 skpsmtpmessage http://code.google.com/p/skpsmtpmessage/을 사용하지만 메일을 Gmail로 보낼 때 첨부 파일로 메시지 본문을 전송합니다.

감사합니다.

+0

은 그럼 당신은 올바르게 사용하고 있지 않습니다. 코드를 제공 할 수 있습니까? 도움이 될 수 있습니다. –

+0

"MessageUI.framework"의 일부인 "MFMailComposeViewController"를 사용합니다. http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html – aminhotob

답변

4

https://github.com/MailCore/mailcore2을 사용해보세요. 이것은 비동기식이며 대부분의 메일 프로토콜을 지원합니다. 메일 보내기 예에서

봐 :

MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init]; 
smtpSession.hostname = @"smtp.gmail.com"; 
smtpSession.port = 465; 
smtpSession.username = @"[email protected]"; 
smtpSession.password = @"password"; 
smtpSession.authType = MCOAuthTypeSASLPlain; 
smtpSession.connectionType = MCOConnectionTypeTLS; 

MCOMessageBuilder *builder = [[MCOMessageBuilder alloc] init]; 
MCOAddress *from = [MCOAddress addressWithDisplayName:@"Matt R" 
             mailbox:@"[email protected]"]; 
MCOAddress *to = [MCOAddress addressWithDisplayName:nil 
            mailbox:@"[email protected]"]; 
[[builder header] setFrom:from]; 
[[builder header] setTo:@[to]]; 
[[builder header] setSubject:@"My message"]; 
[builder setHTMLBody:@"This is a test message!"]; 
NSData * rfc822Data = [builder data]; 

    MCOSMTPSendOperation *sendOperation = 
    [smtpSession sendOperationWithData:rfc822Data]; 
    [sendOperation start:^(NSError *error) { 
    if(error) { 
     NSLog(@"Error sending email: %@", error); 
    } else { 
     NSLog(@"Successfully sent email!"); 
    } 
}]; 
관련 문제