【问题标题】:MailCore 2 - send email Excenge ServerMailCore 2 - 发送电子邮件 Excenge 服务器
【发布时间】:2015-04-18 08:18:22
【问题描述】:

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

我能做什么?

  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!");
    }
}];

【问题讨论】:

  • “无法验证”表示您的登录名和密码错误。

标签: ios xcode smtp mailcore2


【解决方案1】:

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

错字?应该是smtp吗?

【讨论】:

    猜你喜欢
    • 2014-08-12
    • 1970-01-01
    • 2015-09-10
    • 2018-10-17
    • 2012-08-27
    • 2013-04-17
    • 2021-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多