static CURLcode smtp_state_auth_ntlm_type2msg_resp(struct connectdata *conn,
                                                   int smtpcode,
                                                   smtpstate instate)
{
  CURLcode result = CURLE_OK;
  struct SessionHandle *data = conn->data;
  char *type3msg = NULL;
  size_t len = 0;

  (void)instate; /* no use for this yet */

  if(smtpcode != 334) {
    failf(data, "Access denied: %d", smtpcode);
    result = CURLE_LOGIN_DENIED;
  }
  else {
    result = Curl_ntlm_decode_type2_message(data, data->state.buffer + 4,
                                            &conn->ntlm);
    if(!result) {
      result = Curl_ntlm_create_type3_message(conn->data, conn->user,
                                              conn->passwd, &conn->ntlm,
                                              &type3msg, &len);
      if(!result) {
        if(type3msg) {
          result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", type3msg);

          if(!result)
            state(conn, SMTP_AUTH);
        }
        Curl_safefree(type3msg);
      }
    }
  }

  return result;
}
static CURLcode smtp_state_auth_ntlm_type2msg_resp(struct connectdata *conn,
                                                   int smtpcode,
                                                   smtpstate instate)
{
  CURLcode result = CURLE_OK;
  struct SessionHandle *data = conn->data;
  char *type3msg = NULL;
  size_t len = 0;

  (void)instate;  

  if(smtpcode != 334) {
    failf(data, "Access denied: %d", smtpcode);
    result = CURLE_LOGIN_DENIED;
  }
  else {
    result = Curl_ntlm_decode_type2_message(data, data->state.buffer + 4,
                                            &conn->ntlm);
    if(!result) {
      result = Curl_ntlm_create_type3_message(conn->data, conn->user,
                                              conn->passwd, &conn->ntlm,
                                              &type3msg, &len);
      if(!result) {
        if(type3msg) {
          result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", type3msg);

          if(!result)
            state(conn, SMTP_AUTH);
        }
        Curl_safefree(type3msg);
      }
    }
  }

  return result;
}