title: SMTP: An error occurred while sending the message
body: <p>I have Gmail working in my iOS app via OAuth and IMAP/SMTP. If I use another account though the SMTP won't work. I've tried with a email account on a custom domain (through Host Gator) and with an outlook.com account. IMAP works fine, it's just sending that fails. I have checked connection logger and get the following:</p>
  
  <pre><code>event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 220 BLU436-SMTP189.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at  Wed, 7 Jan 2015 04:03:35 -0800 
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 1 withData: EHLO -iPad
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 250-BLU436-SMTP189.smtp.hotmail.com Hello [80.194.198.170]
  
  250-TURN
  
  250-SIZE 41943040
  
  250-ETRN
  
  250-PIPELINING
  
  250-DSN
  
  250-ENHANCEDSTATUSCODES
  
  250-8bitmime
  
  250-BINARYMIME
  
  250-CHUNKING
  
  250-VRFY
  
  250-TLS
  
  250-STARTTLS
  
  250 OK
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 1 withData: STARTTLS
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 220 2.0.0 SMTP server ready
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 1 withData: EHLO -iPad
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 250-BLU436-SMTP189.smtp.hotmail.com Hello [80.194.198.170]
  
  250-TURN
  
  250-SIZE 41943040
  
  250-ETRN
  
  250-PIPELINING
  
  250-DSN
  
  250-ENHANCEDSTATUSCODES
  
  250-8bitmime
  
  250-BINARYMIME
  
  250-CHUNKING
  
  250-VRFY
  
  250-AUTH LOGIN PLAIN XOAUTH2
  
  250 OK
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 2 withData: AUTH PLAIN a21jZ3JhZHlAb3V0bG9vay5jb20Aa21jZ3JhZHlAb3V0bG9vay5jb20AQWZ0ZXJlZmZlY3RzMT8=
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 235 2.7.0 Authentication succeeded
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 1 withData: MAIL FROM:&lt;myemail@outlook.com&gt;
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 250 2.1.0 myemail@outlook.com....Sender OK
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 1 withData: RCPT TO:&lt;email@invalid.com&gt;
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 250 2.1.5 email@invalid.com 
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 1 withData: MAIL FROM:&lt;myemail@outlook.com&gt; SIZE=799
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 0 withData: 503 5.5.2 Sender already specified
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 1 withData: QUIT
  
  event logged:0x18141580 -1 withData: 
  event logged:0x18141580 -1 withData: 
  </code></pre>
  
  <p>My SMTP settings are:</p>
  
  <p>Email</p>
  
  <p>Password</p>
  
  <p>Port 25 (also tried 587)</p>
  
  <p>MCOConnectionTypeStartTLS (also tried MCOConnectionTypeTLS)</p>
  
  <p>MCOAuthTypeSASLNone</p>
  
  <p>In sendOperationWithData: I get the following error: <code>Error Domain=MCOErrorDomain Code=30 "An error occured while sending the message."</code></p>
  
  <p>This is the code to send:</p>
  
  <pre><code>  MCOAddress *address= [MCOAddress addressWithDisplayName:currentAccount.name mailbox:smtp_email];
  
  MCOSMTPOperation * op = [currentSMTPSession checkAccountOperationWithFrom:address];
          [op start:^(NSError * error) {
  
              }
  </code></pre>
  
  <p>And I configure the SMTP (called before the send operation) like this:</p>
  
  <pre><code>    if (currentSMTPSession == nil) {
      currentSMTPSession = [[MCOSMTPSession alloc] init];
  }
  
  [currentSMTPSession setHostname:currentAccount.smtp_server];
  [currentSMTPSession setUsername:currentAccount.smtp_email];
  [currentSMTPSession setPassword:currentAccount.smtp_password];
  [currentSMTPSession setPort:currentAccount.smtp_port.intValue];
  [currentSMTPSession setConnectionType:MCOConnectionTypeStartTLS];
  [currentSMTPSession setOAuth2Token:currentAccount.oauthToken];
  [currentSMTPSession setAuthType:MCOAuthTypeSASLNone]
  </code></pre>