autoconfig email client (Thunderbird)

/var/www/mail/config-v1.1.xml.php

<?php
$emailaddress = $_GET["emailaddress"];
$username = "%EMAILADDRESS%";
$password = "";
 
switch ($emailaddress) {
    case "foo@example.com":
        $username = "foo";
        $password = "pass1234";
        break;
}
 
header('Content-type: text/xml');
?>
 
<clientConfig version="1.1">
<emailProvider id="example.com">
    <domain>example.com</domain>
    <domain>example.net</domain>
 
    <displayName>Foo Inc.</displayName>
    <displayShortName>mr</displayShortName>
 
    <incomingServer type="imap">
        <hostname>imap.example.com</hostname>
        <port>143</port>
        <socketType>STARTTLS</socketType>
        <authentication>password-cleartext</authentication>
        <username><?php echo($username); ?></username>
        <password><?php echo($password); ?></password>
    </incomingServer>
 
    <outgoingServer type="smtp">
        <hostname>smtp.example.com</hostname>
        <port>25</port>
        <socketType>STARTTLS</socketType>
        <authentication>password-cleartext</authentication>
        <username><?php echo($username); ?></username>
        <password><?php echo($password); ?></password>
    </outgoingServer>
</emailProvider>
</clientConfig>

Links
https://www.heise.de/ct/ausgabe/2013-8-Selbstkonfiguration-von-E-Mail-Clients-2324925.html
https://developer.mozilla.org/de/docs/Mozilla/Thunderbird/Autokonfiguration