set -e; command -v timeout >/dev/null; tty_state=$(stty -g); trap 'stty "$tty_state"' EXIT; stty icanon -echo; timeout --foreground --signal=TERM --kill-after=5s 420s php artisan tinker --execute='(function () { if (!stream_isatty(STDIN)) { echo "probe_requires_tty\n"; return; } if (!(new ReflectionMethod(\Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport::class, '"'"'start'"'"'))->isPublic()) { echo "probe_api_unavailable\n"; return; } set_error_handler(static function () { return true; }); try { echo '"'"'Relay credential:'"'"'; fflush(STDOUT); $read = [STDIN]; $write = $except = []; if (stream_select($read, $write, $except, 300) !== 1) { echo "input_timeout_or_unavailable\n"; return; } $line = fgets(STDIN); if ($line === false) { echo "input_unavailable\n"; return; } $secret = rtrim($line, "\r\n"); unset($line); if ($secret === '"'"''"'"' || preg_match('"'"'/[\x00-\x1F\x7F]/'"'"', $secret)) { unset($secret); echo "input_invalid\n"; return; } echo PHP_EOL; foreach (['"'"'iota.post.nuhet.se'"'"', '"'"'kappa.post.nuhet.se'"'"', '"'"'lambda.post.nuhet.se'"'"', '"'"'mu.post.nuhet.se'"'"'] as $host) { $transport = null; $result = ['"'"'host'"'"' => $host, '"'"'port'"'"' => 465, '"'"'auth_ok'"'"' => false, '"'"'quit_ack'"'"' => false]; try { $transport = new class ($host, 465, true) extends \Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport { public bool $quitAcknowledged = false; public function executeCommand(string $command, array $codes): string { $response = parent::executeCommand($command, $codes); if ($command === "QUIT\r\n" && in_array(221, $codes, true)) { $this->quitAcknowledged = true; } return $response; } }; $transport->getStream()->setTimeout(8); $transport->setUsername('"'"''"'"'); $transport->start(); $transport->setUsername('"'"'nuhet_auth_1'"'"'); $transport->setPassword($secret); (new \Symfony\Component\Mailer\Transport\Smtp\Auth\PlainAuthenticator())->authenticate($transport); $result['"'"'auth_ok'"'"'] = true; } catch (\Throwable $error) { $result['"'"'error_class'"'"'] = get_class($error); $result['"'"'error_code'"'"'] = (int) $error->getCode(); } finally { if ($transport !== null) { try { $transport->stop(); } catch (\Throwable $error) { } $result['"'"'quit_ack'"'"'] = $transport->quitAcknowledged; } } echo json_encode($result, JSON_UNESCAPED_SLASHES).PHP_EOL; unset($transport); } unset($secret); } catch (\Throwable $error) { unset($secret, $line, $transport); echo "probe_failed_without_details\n"; } finally { restore_error_handler(); } })(); '