gpt4 book ai didi

ios - MailCore 2 - 发送电子邮件 Excenge 服务器

转载 作者:行者123 更新时间:2023-11-29 10:33:03 25 4
gpt4 key购买 nike

我正在尝试使用 Exchange 服务器从我的应用程序发送电子邮件。但我不断收到“无法使用当前 session 的凭据进行身份验证”。我注释掉了我尝试过的所有内容,如主机名、端口或连接类型。

我能做什么?

  MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init];
smtpSession.hostname = @"smpt.office365.com";
//smtpSession.hostname = @"smpt.outlook.office365.com";
//smtpSession.port = 587;
smtpSession.port = 25;
smtpSession.username = @"";
smtpSession.password = @"";
smtpSession.authType = MCOAuthTypeSASLPlain;
//smtpSession.connectionType = MCOConnectionTypeTLS;
smtpSession.connectionType = MCOConnectionTypeStartTLS;

MCOMessageBuilder *builder = [[MCOMessageBuilder alloc] init];
MCOAddress *from = [MCOAddress addressWithDisplayName:@""
mailbox:@""];
MCOAddress *to = [MCOAddress addressWithDisplayName:nil
mailbox:@""];
[[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!");
}
}];

最佳答案

smtpSession.hostname = @"smpt.office365.com";
^^^^

打字错误?应该是 smtp 吗?

关于ios - MailCore 2 - 发送电子邮件 Excenge 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28564842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com