我在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;
怎么了?我收到错误->无法建立与服务器的稳定连接。
答案 0 :(得分: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)")
}
}
}