/** * * @param unknown $host * @param unknown $port */ function test($host, $port, $tests, $expectedResult) { $p = new PostmanPortTest($host, $port); $success = false; if ($tests & SMTP) { $success = $p->testSmtpPorts(TIMEOUT, TIMEOUT); } elseif ($tests & SMTPS) { $success = $p->testSmtpsPorts(TIMEOUT, TIMEOUT); } if ($tests & STARTTLS) { $success &= $p->startTls; } if ($tests & CRAMMD5) { $success &= $p->authCrammd5; } if ($tests & XOAUTH) { $success &= $p->authXoauth; } if ($tests & LOGIN) { $success &= $p->authLogin; } if ($tests & PLAIN) { $success &= $p->authPlain; } $displaySuccess = 'fail'; if ($success == $expectedResult) { $displaySuccess = 'pass'; } print "{$displaySuccess}: {$host}:{$port}\n"; }
/** * This Ajax function retrieves whether a TCP port is open or not. * This is called by both the Wizard and Port Test */ function runSmtpTest() { $hostname = trim(PostmanUtils::getRequestParameter('hostname')); $port = intval(PostmanUtils::getRequestParameter('port')); $transport = trim(PostmanUtils::getRequestParameter('transport')); $timeout = PostmanUtils::getRequestParameter('timeout'); $this->logger->trace($timeout); $portTest = new PostmanPortTest($hostname, $port); if (isset($timeout)) { $portTest->setConnectionTimeout(intval($timeout)); $portTest->setReadTimeout(intval($timeout)); } if ($port != 443) { $this->logger->debug(sprintf('testing SMTP socket %s:%s (%s)', $hostname, $port, $transport)); $success = $portTest->testSmtpPorts(); } else { $this->logger->debug(sprintf('testing HTTPS socket %s:%s (%s)', $hostname, $port, $transport)); $success = $portTest->testHttpPorts(); } $this->buildResponse($hostname, $port, $portTest, $success, $transport); }
/** * This Ajax function retrieves whether a TCP port is open or not */ function runSmtpTest() { $hostname = trim($this->getRequestParameter('hostname')); $port = intval($this->getRequestParameter('port')); $timeout = $this->getRequestParameter('timeout'); $this->logger->trace($timeout); $portTest = new PostmanPortTest($hostname, $port); if (isset($timeout)) { $portTest->setConnectionTimeout(intval($timeout)); $portTest->setReadTimeout(intval($timeout)); } if ($port != 443) { $this->logger->debug('testing SMTP port: hostname ' . $hostname . ' port ' . $port); $success = $portTest->testSmtpPorts(); } else { $this->logger->debug('testing HTTPS port: hostname ' . $hostname . ' port ' . $port); $success = $portTest->testHttpPorts(); } $this->buildResponse($hostname, $port, $portTest, $success); }