Search code examples
mailcore2

What is exactly hostname for sending Microsoft Exchange email with mailcore


I can not send MS Exchange email with mailcore. It always returns an error "A stable connection to the server could not be established". Here is my code

    smtpSession.hostname = @"smtp.outlook.office365.co.uk";
    smtpSession.username = [currentUser objectForKey:@"email_account"];
    smtpSession.password = [currentUser objectForKey:@"email_password"];
    smtpSession.port = 25;
    smtpSession.connectionType = MCOConnectionTypeClear;

I think it because of the hostname. Could anybody tell me what is exactly hostname of MS Exchange in this case?


Solution

  • Finally, I found out answer here

    smtpSession.hostname = @"smtp.office365.com";
        smtpSession.username = [currentUser objectForKey:@"email_account"];
        smtpSession.password = [currentUser objectForKey:@"email_password"];
        smtpSession.port = 25;
        smtpSession.connectionType = MCOConnectionTypeStartTLS;