0

尝试关注: http: //libmailcore.com/gettingstarted.html

-(void) testSend{

    CTCoreMessage *msg = [[CTCoreMessage alloc] init];
    CTCoreAddress *toAddress = [CTCoreAddress addressWithName:@"Monkey"
                                                        email:@"....@gmail.com"];
    [msg setTo:[NSSet setWithObject:toAddress]];
    [msg setBody:@"This is a test message!"];

    NSError *error;
    BOOL success = [CTSMTPConnection sendMessage:msg
                                          server:@"smtp.gmail.com"
                                        username:@".....@gmail.com"
                                        password:@"......"
                                            port:587
                                  connectionType:CTSMTPConnectionTypeStartTLS
                                         useAuth:YES
                                           error:&error];
    if(success){
        NSLog(@"%s","SUCESS SEND");
    }else{
         NSLog(@"%s","FAILED SEND");
    }

}

有用

-(void) testGet{

      CTCoreAccount *account = [[CTCoreAccount alloc] init];
      BOOL success = [account connectToServer:@"imap.gmail.com"
                                   port:993
                         connectionType:CTConnectionTypePlain
                               authType:CTImapAuthTypePlain
                                  login:@"........"
                               password:@"......."];
if(success){
    NSLog(@"%s","SUCESS GET");
}else{
    NSLog(@"%s","FAILED GET");
}
}

它不起作用

我的错误在哪里?

4

1 回答 1

-1
#define GMAIL_SERVER        @"imap.gmail.com"
#define GMAIL_PORT              993
#define GMAIL_CONNECTION_TYPE   CONNECTION_TYPE_TLS
#define GMAIL_AUTH_TYPE         IMAP_AUTH_TYPE_PLAIN

CTCoreAccount *account = [[CTCoreAccount alloc] init];
BOOL success = [account connectToServer:GMAIL_SERVER
                                   port:GMAIL_PORT
                         connectionType:GMAIL_CONNECTION_TYPE
                               authType:GMAIL_AUTH_TYPE

这个对我有用

于 2013-05-03T23:50:28.613 回答