2010-08-09 5 views
0

любой знает библиотеку объектно-c smtp для использования в приложении iphone.iphone smtp клиентская библиотека

Я использую skpsmtpmessage http://code.google.com/p/skpsmtpmessage/, но отправляет сообщение в качестве приложенного письма при отправке почты в gmail.

спасибо.

+0

Тогда вы не используете его правильно. Можете ли вы предоставить код? что могло бы помочь. –

+0

Теперь я использую «MFMailComposeViewController», он является частью «MessageUI.framework» 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!"); 
    } 
}]; 
Смежные вопросы