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

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

  if(smtpcode != 334) {
    failf(data, "Access denied: %d", smtpcode);
    result = CURLE_LOGIN_DENIED;
  }
  else {
    plen = strlen(conn->passwd);

    if(!plen)
      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "=");
    else {
      result = Curl_base64_encode(data, conn->passwd, plen, &authpasswd, &len);

      if(!result) {
        if(authpasswd) {
          result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd);

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

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

  (void)instate;  

  if(smtpcode != 334) {
    failf(data, "Access denied: %d", smtpcode);
    result = CURLE_LOGIN_DENIED;
  }
  else {
    plen = strlen(conn->passwd);

    if(!plen)
      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "=");
    else {
      result = Curl_base64_encode(data, conn->passwd, plen, &authpasswd, &len);

      if(!result) {
        if(authpasswd) {
          result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", authpasswd);

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

  return result;
}