Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] - Check connection is not printing any output #1995

Open
kumarkrish85 opened this issue Feb 13, 2024 · 2 comments
Open

[Bug] - Check connection is not printing any output #1995

kumarkrish85 opened this issue Feb 13, 2024 · 2 comments
Labels

Comments

@kumarkrish85
Copy link

Summary
Hello I am trying to connect my company mail server to fetch mail, but i am trying to make a connection to server using the below code, but nothing it get printed , please guide me. I can connect the same server through python imap library

Platform(s)
IOS

Happens on Mail Server
Outlook365

Piece of code

let session = MCOIMAPSession()
        session.hostname = ""
        session.username = "[email protected]"
        session.password = "Welcome2024#"
        session.port = 993
        session.allowsFolderConcurrentAccessEnabled = true
        session.connectionType              = MCOConnectionType.TLS
        session.authType                    = MCOAuthType.saslLogin
        session.isCheckCertificateEnabled   = false
        session.isVoIPEnabled               = false
        session.maximumConnections          = 2
        session.timeout                     = 10
        
        if let loginOperation = session.checkAccountOperation() {
            loginOperation.start { (error) -> Void in
                if (error != nil) {
                    print("Error login:\n\(String(describing: error))")
                } else {
                    print("imapConnect - Successful IMAP connection")
                }
            }
        }

Actual outcome
It didn't print anything

Connection Logs

Kindly let me know how to generate connection logs

Expected outcome
Mailcore should connect my mail server successfully

@Be-Maps
Copy link

Be-Maps commented Feb 14, 2024

One of the 2 below usually works, I am not sure if you deleted or you did not give hostname in code above (i.e. imap.*****.com).
Also check the ports, which are used for IMAP TLS or SSL.

if (config.getIMAPSSL().equals("SSL")){
                        session.hostname = config.getIMAPServer()
                        session.username = config.getUserName()
                        session.password = config.getPassword()
                        session.port = UInt32.parseUInt32(config.getIMAPport())
                        session.allowsFolderConcurrentAccessEnabled = true
                        session.connectionType              = MCOConnectionType.TLS
                        session.authType                    = MCOAuthType.saslLogin
                        session.isCheckCertificateEnabled   = false
                        session.isVoIPEnabled               = false
                        session.maximumConnections          = 2
                        session.timeout                     = App.connectionTimeout
                    } else {
                        session.hostname = config.getIMAPServer()
                        session.username = config.getUserName()
                        session.password = config.getPassword()
                        session.port = UInt32.parseUInt32(config.getIMAPport())
                        session.allowsFolderConcurrentAccessEnabled = true
                        session.connectionType              = MCOConnectionType.startTLS
                        session.authType                    = MCOAuthType.saslPlain
                        session.isCheckCertificateEnabled   = false
                        session.isVoIPEnabled               = false
                        session.maximumConnections          = 2
                        session.timeout                     = App.connectionTimeout
                    }

    if let loginOperation = session.checkAccountOperation() {
        do { try await loginOperation.start(); print("imapConnect - Successful IMAP connection") }
        catch { print("imapConnect - IMAP Connect Error: \(error)"); return }
    }

@kumarkrish85
Copy link
Author

@Be-Maps Thanks for the reply. I didn't give the hostname in the query for masking. I will try your suggestion and get back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants