首页 > 解决方案 > MAILCORE2 - 无法建立与服务器的稳定连接

问题描述

我在我们的 Xcode 项目 Cobj 中设置了 MailCore2 插件,但它不起作用...我的电子邮件地址是 Apple 帐户 ....@mac.com 我的详细信息是:

#define kmailAdminHost          @"smtp.mail.me.com"
#define kmailAdminUser          @"<apple email address>" 
#define kmailAdminPassword      @"<password>"
#define kmailAdminPort          587

    smtpSession.hostname = kmailAdminHost;
    smtpSession.port     = kmailAdminPort;
    smtpSession.username = kmailAdminUser;
    smtpSession.password = kmailAdminPassword;
    smtpSession.connectionType = MCOConnectionTypeTLS;
    smtpSession.authType = MCOAuthTypeSASLPlain;
    smtpSession.checkCertificateEnabled = false ;
    smtpSession.timeout = 30.0;

怎么了?我收到错误 -> 无法建立与服务器的稳定连接。

标签: iosxcodemailcore2

解决方案


大家好,我也遇到过同样的情况,并且在像这样更改端口地址和身份验证类型后发现这段代码对我有用。

        smtpSession.hostname = "smtp.gmail.com"
        smtpSession.username = "........."
        smtpSession.password = "........."
        smtpSession.port = 465
        smtpSession.authType = MCOAuthType.saslPlain
        smtpSession.connectionType = MCOConnectionType.TLS
        smtpSession.connectionLogger = {(connectionID, type, data) in
            if data != nil {
                if let string = NSString(data: data!, encoding: String.Encoding.utf8.rawValue){
                    NSLog("Connectionlogger: \(string)")
                }
            }
        }

推荐阅读