You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
845 B
15 lines
845 B
<?php
|
|
require_once __DIR__ . '/SmtpServer.php';
|
|
require_once __DIR__ . '/../utils/Config.php';
|
|
require_once __DIR__ . '/../utils/Logger.php';
|
|
$options = getopt("h:p:m:", ["host:", "port:", "max-connections:", "help"]);
|
|
if (isset($options['help'])) { echo "SMTP Server Usage\n"; exit(0); }
|
|
$config = Config::getInstance();
|
|
$host = $options['h'] ?? $options['host'] ?? $config->get('smtp.host', '0.0.0.0');
|
|
$port = (int)($options['p'] ?? $options['port'] ?? $config->get('smtp.port', 25));
|
|
$maxConnections = (int)($options['m'] ?? $options['max-connections'] ?? $config->get('smtp.max_connections', 100));
|
|
if ($port < 1 || $port > 65535) { echo "Invalid port\n"; exit(1); }
|
|
if ($maxConnections < 1 || $maxConnections > 1000) { echo "Invalid max connections\n"; exit(1); }
|
|
$server = new SmtpServer($host, $port, $maxConnections);
|
|
$server->start();
|