hechengjin 发表于 2016-3-27 22:28:08

账号配置向导

const UNKNOWN = -1;const IMAP = 0;const POP = 1;const SMTP = 2;

// Security Typesconst NONE = 0; // no encryption//1 would be "TLS if available"const TLS = 3; // STARTTLSconst SSL = 2; // SSL / TLS


2014-12-23 09:24:59      mail.wizard      INFO      doing auto detect for protocol 1, domain pop3.sgcc.com.cn, (exactly: true), port 995, ssl 2

2014-12-23 09:24:59      mail.wizard      INFO      poking at pop3.sgcc.com.cn port 995 ssl 2 protocol pop3

2014-12-23 09:24:59      mail.wizard      INFO      progress callback host pop3.sgcc.com.cn port 995 type pop3


const CMDS = {}
CMDS = ["1 CAPABILITY\r\n", "2 LOGOUT\r\n"];
CMDS = ["CAPA\r\n", "QUIT\r\n"];
// CMDS = ["EHLO we-guess.mozilla.org\r\n", "QUIT\r\n"];

// only say hello?
CMDS = ["EHLO richinfo.cn\r\n", "QUIT\r\n"];function guessConfig(domain, progressCallback, successCallback, errorCallback,
                     resultConfig, which)
{
incomingHostDetector = new IncomingHostDetector(progress, incomingSuccess,
                                                incomingError);

if (which == "incoming" || which == "both")
{
    incomingHostDetector.start(resultConfig.incoming.hostname ?
            resultConfig.incoming.hostname : domain,
      !!resultConfig.incoming.hostname, resultConfig.incoming.type,
      resultConfig.incoming.port, resultConfig.incoming.socketType);
}

}

function IncomingHostDetector(
progressCallback, successCallback, errorCallback)
{
HostDetector.call(this, progressCallback, successCallback, errorCallback);
}
IncomingHostDetector.prototype =
{
_hostnamesToTry : function(protocol, domain)
{
    var hostnamesToTry = [];
    if (protocol != POP)
      hostnamesToTry.push("imap." +domain);
    if (protocol != IMAP)
    {
      hostnamesToTry.push("pop3." +domain);
      hostnamesToTry.push("pop." +domain);
    }
   // hostnamesToTry.push("mail." + domain);
   // hostnamesToTry.push(domain);
    return hostnamesToTry;
},
_portsToTry : getIncomingTryOrder,
}
extend(IncomingHostDetector, HostDetector);

function HostDetector(progressCallback, successCallback, errorCallback)
{
}
HostDetector.prototype =
{
start : function(domain, hostIsPrecise, type, port, socketType)
{
this._log.info("doing auto detect for protocol " + protocol +
      ", domain " + domain + ", (exactly: " + hostIsPrecise +
      "), port " + port + ", ssl " + ssl);
   this._tryAll();
}
}
_tryAll : function()
{
this._log.info("poking at " + thisTry.hostname + " port " +
          thisTry.port + " ssl "+ thisTry.ssl + " protocol " +
          protocolToString(thisTry.protocol));

    this.mProgressCallback(thisTry);
    thisTry.abortable = SocketUtil(
          thisTry.hostname, thisTry.port, thisTry.ssl,
          thisTry.commands, TIMEOUT,
          new SSLErrorHandler(thisTry, this._log),
          function(wiredata) // result callback
          {/*----------使用无效的证书后,返回的wiredata为空,虽然抓包有数据返回------
imap.sgcc.com.cn:993 使用了无效的安全证书。
该证书因为其自签名而不被信任。该证书对任意服务器名均无效。(错误码: sec_error_untrusted_issuer)


*/
            if (me._cancel)
            return; // don't use response anymore
            me.mProgressCallback(thisTry);
            me._processResult(thisTry, wiredata);
            me._checkFinished();
          },
          function(e) // error callback
          {
            if (me._cancel)
            return; // who set cancel to true already called mErrorCallback()
            me._log.warn(e);
            thisTry.status = kFailed;
            me._checkFinished();
          });
}
页: [1]
查看完整版本: 账号配置向导