0

iPhoneアプリで使用するためのobjective-c smtpライブラリを知っている人は誰でもいます。

私は skpsmtpmessage http://code.google.com/p/skpsmtpmessage/を使用 していますが、gmail にメールを送信するときにメッセージ本文を添付ファイルとして送信します。

ありがとう。

4

2 に答える 2

4

https://github.com/MailCore/mailcore2を使用してみてください。これは非同期で、ほとんどのメール プロトコルをサポートします。

メールの送信例を見てください:

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

 MCOMessageBuilder *builder = [[MCOMessageBuilder alloc] init];
 MCOAddress *from = [MCOAddress addressWithDisplayName:@"Matt R"
                                      mailbox:@"matt@gmail.com"];
 MCOAddress *to = [MCOAddress addressWithDisplayName:nil 
                                    mailbox:@"hoa@gmail.com"];
 [[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!");
   }
}];
于 2013-12-11T11:34:52.827 に答える