我在Xcode项目Cobj中安装了MailCore2插件,但它不起作用。。。我的电子邮件地址是一个苹果帐户@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)")
}
}
}