MAILCORE2 - A stable connection to the server could not be established

275 Views Asked by At

I setup the MailCore2 plugin in our Xcode project Cobj and it doesn’t work...my email address is an Apple account [email protected] my details are:

#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;

What is wrong? I get the error -> A stable connection to the server could not be established.

1

There are 1 best solutions below

0
Dheeraj On

Hello folk I've also faced the same situation and figure out that this code works for me after changing port address and auth type like this.

        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)")
                }
            }
        }