(.*)<\/EMailAddress>/', $raw, $matches) === 1) { parseMail($matches[1]); } else { $domainPart = array_slice(explode('.', $_SERVER['HTTP_HOST']), -2); $domain = implode('.', $domainPart); } $template = 'autodiscover.xml'; break; case '/mail/config-v1.1.xml': case '/.well-known/autoconfig/mail/config-v1.1.xml': $user = '%EMAILLOCALPART%'; $domain = '%EMAILDOMAIN%'; $template = 'autoconfig.xml'; if (isset($_GET['emailaddress'])) parseMail($_GET['emailaddress']); break; default: header('HTTP/1.0 404 Not Found'); exit; } $config = require('/etc/vn-autoconfig/config.php'); extract($config); $finalDefaults = [ 'imapServer' => "imap.$domain", 'imapPort' => 993, 'smtpServer' => "smtp.$domain", 'smtpPort' => 465 ]; extract($finalDefaults, EXTR_SKIP); header('Content-type: application/xml'); include($template);