2015-02-17 5 views
1

Я пытаюсь отправить электронное письмо из своего приложения с сервером Exchange. Но я продолжаю получать «Не удалось аутентифицироваться с учетными данными текущего сеанса». Я прокомментировал все, что я пробовал, как имя хоста, порт или тип подключения.MailCore 2 - отправить электронное письмо Excenge Server

Что я могу сделать?

MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init]; 
smtpSession.hostname = @"smpt.office365.com"; 
//smtpSession.hostname = @"smpt.outlook.office365.com"; 
//smtpSession.port = 587; 
smtpSession.port = 25; 
smtpSession.username = @""; 
smtpSession.password = @""; 
smtpSession.authType = MCOAuthTypeSASLPlain; 
//smtpSession.connectionType = MCOConnectionTypeTLS; 
smtpSession.connectionType = MCOConnectionTypeStartTLS; 

MCOMessageBuilder *builder = [[MCOMessageBuilder alloc] init]; 
MCOAddress *from = [MCOAddress addressWithDisplayName:@"" 
               mailbox:@""]; 
MCOAddress *to = [MCOAddress addressWithDisplayName:nil 
              mailbox:@""]; 
[[builder header] setFrom:from]; 
[[builder header] setTo:@[to]]; 
[[builder header] setSubject:@"My message"]; 
[builder setHTMLBody:@"This is a test message!"]; 
NSData * rfc822Data = [builder data]; 

MCOSMTPSendOperation *sendOperation = 
[smtpSession sendOperationWithData:rfc822Data]; 
[sendOperation start:^(NSError *error) { 
    if(error) { 
     NSLog(@"Error sending email: %@", error); 
    } else { 
     NSLog(@"Successfully sent email!"); 
    } 
}]; 
+0

«Не удалось аутентифицировать» означает, что ваш логин и пароль неверны. –

ответ

2

smtpSession.hostname = @"smpt.office365.com"; ^^^^

Опечатка? Должно ли это быть smtp?

Смежные вопросы