/** * * @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"; }
/** * Diagnostic Data test to current SMTP server * * @return string */ private function testConnectivity(PostmanModuleTransport $transport) { $hostname = $transport->getHostname($this->options); $port = $transport->getPort($this->options); if (!empty($hostname) && !empty($port)) { $portTest = new PostmanPortTest($transport->getHostname($this->options), $transport->getPort($this->options)); $result = $portTest->genericConnectionTest($this->options->getConnectionTimeout()); if ($result) { return 'Yes'; } else { return 'No'; } } return 'n/a'; }
/** * * @param unknown $hostname * @param unknown $port * @param unknown $success */ private function buildResponse($hostname, $port, PostmanPortTest $portTest, $success, $transport = '') { $this->logger->debug(sprintf('testing port result for %s:%s success=%s', $hostname, $port, $success)); $response = array('hostname' => $hostname, 'hostname_domain_only' => $portTest->hostnameDomainOnly, 'port' => $port, 'protocol' => $portTest->protocol, 'secure' => $portTest->secure, 'mitm' => $portTest->mitm, 'reported_hostname' => $portTest->reportedHostname, 'reported_hostname_domain_only' => $portTest->reportedHostnameDomainOnly, 'message' => $portTest->getErrorMessage(), 'start_tls' => $portTest->startTls, 'auth_plain' => $portTest->authPlain, 'auth_login' => $portTest->authLogin, 'auth_crammd5' => $portTest->authCrammd5, 'auth_xoauth' => $portTest->authXoauth, 'auth_none' => $portTest->authNone, 'try_smtps' => $portTest->trySmtps, 'success' => $success, 'transport' => $transport); $this->logger->trace('Ajax response:'); $this->logger->trace($response); if ($success) { wp_send_json_success($response); } else { wp_send_json_error($response); } }