MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.61k stars 624 forks source link

SMTP AuthType:MCOAuthTypeSASLNTLM errorLog:No worthy mechs found #1875

Open VictorLiChou opened 4 years ago

VictorLiChou commented 4 years ago

Login with imap is OK, But I got these log when I tried to login with smtp:No worthy mechs found, I'm looking for help. Thanks.

[Development environment] MailCore2 (Branch Master) Simulator (iPhone 7 Plus) XCode 11.4.1 Objective C

[Log]

2020-05-21 15:28:58.173872+0800 MailCore2Demo[32504:3732305] smtp log: 220 SHC-W0312227.stgdom.local Microsoft ESMTP MAIL Service ready at Thu, 21 May 2020 15:28:57 +0800
2020-05-21 15:28:58.174216+0800 MailCore2Demo[32504:3732305] smtp log: EHLO zhoulideMacBook-Pro.local
2020-05-21 15:28:58.219764+0800 MailCore2Demo[32504:3732305] smtp log: 250-SHC-W0312227.stgdom.local Hello [30.5.160.20]
250-SIZE 24117248
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-X-ANONYMOUSTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-X-EXPS GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 XRDST
2020-05-21 15:28:58.222792+0800 MailCore2Demo[32504:3732305] No worthy mechs found
2020-05-21 15:28:58.223952+0800 MailCore2Demo[32504:3732075] smtp error: Error Domain=MCOErrorDomain Code=5 "Unable to authenticate with the current session's credentials." UserInfo={MCOSMTPResponseCodeKey=250, NSLocalizedDescription=Unable to authenticate with the current session's credentials., MCOSMTPResponseKey=SHC-W0312227.stgdom.local Hello [30.5.160.20]
SIZE 24117248
PIPELINING
DSN
ENHANCEDSTATUSCODES
STARTTLS
X-ANONYMOUSTLS
AUTH LOGIN PLAIN
AUTH=LOGIN PLAIN
X-EXPS GSSAPI NTLM
8BITMIME
BINARYMIME
CHUNKING
XRDST
}

[Source Code]

MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init];
smtpSession.checkCertificateEnabled = NO;
smtpSession.authType = MCOAuthTypeSASLNTLM;
smtpSession.connectionType = MCOConnectionTypeTLS;
smtpSession.timeout = 60;
smtpSession.hostname = @"xxxx.xxx.com";
smtpSession.username = @"xxxxx";
smtpSession.password = @"xxxxx";
smtpSession.port = xxxx;

smtpSession.connectionLogger = ^(void *connectionID, MCOConnectionLogType type, NSData *data) {
        NSString *log = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"smtp log: %@", log);
};

MCOSMTPOperation *op = [smtpSession loginOperation];
[op start:^(NSError * error) {
        if (error) {
            NSLog(@"smtp error: %@", error);
        } else {
            NSLog(@"smtp success");
        }
}];
davidzhou23 commented 3 years ago

smtp 支持 250-AUTH LOGIN PLAIN 不需要配置 smtpSession.authType = MCOAuthTypeSASLNTLM; 目前你的SMTP不支持 NTLM的验证方式