ios - 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;
怎么了?我收到错误 -> 无法建立与服务器的稳定连接。
解决方案
大家好,我也遇到过同样的情况,并且在像这样更改端口地址和身份验证类型后发现这段代码对我有用。
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)")
}
}
}
推荐阅读
- sql - 如何在触发器中实现我的功能?
- c++ - 为什么 ifstream 不读取任何内容
- java - 将单独的 Java 应用程序集成为单个应用程序的模块
- amazon-web-services - 将多个 Route53 子域指向单个 S3 存储桶
- javascript - JavaScript 可以安全地从不受信任的域中获取数据吗?
- nlp - 查找目标和中心 word2vec 矩阵
- c++ - 将字符串推送到私有成员向量
- c# - Visual Studio 2019 终止后台进程 - 高 CPU 使用率、滞后
- graphql - 重载 GraphQL Schema 以支持通过用户名或密码获取用户
- r - 如何根据给定的门牌号和邮政编码返回门牌号值