(email_settings) {
    # 1. Autodiscover für Outlook
    route /autodiscover/autodiscover.xml {
        header Content-Type "application/xml"
        # Wir nutzen {header.X-Anchormailbox} um die Email dynamisch einzufügen
        respond `<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
  <Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
    <Account>
      <AccountType>email</AccountType>
      <Action>settings</Action>
      <Protocol>
        <Type>IMAP</Type>
        <Server>mail.email-srvr.com</Server>
        <Port>993</Port>
        <DomainRequired>on</DomainRequired>
        <LoginName>{header.X-Anchormailbox}</LoginName>
        <SPA>off</SPA>
        <SSL>on</SSL>
        <AuthRequired>on</AuthRequired>
      </Protocol>
      <Protocol>
        <Type>POP3</Type>
        <Server>mail.email-srvr.com</Server>
        <Port>995</Port>
        <DomainRequired>on</DomainRequired>
        <LoginName>{header.X-Anchormailbox}</LoginName>
        <SPA>off</SPA>
        <SSL>on</SSL>
        <AuthRequired>on</AuthRequired>
      </Protocol>      
      <Protocol>
        <Type>SMTP</Type>
        <Server>mail.email-srvr.com</Server>
        <Port>465</Port>
        <DomainRequired>on</DomainRequired>
        <LoginName>{header.X-Anchormailbox}</LoginName>
        <SPA>off</SPA>
        <SSL>on</SSL>
        <AuthRequired>on</AuthRequired>
      </Protocol>
    </Account>
  </Response>
</Autodiscover>` 200
    }

    # 2. JSON Autodiscover (Modern Outlook) - bleibt gleich
    route /autodiscover/autodiscover.json {
        header Content-Type "application/json"
        respond `{
            "Protocol": "AutodiscoverV1",
            "Url": "https://autodiscover.bayarea-cc.com/autodiscover/autodiscover.xml"
        }` 200
    }

    # 3. Thunderbird Autoconfig - bleibt gleich (dort funktioniert %EMAILADDRESS% ja nativ)
    route /mail/config-v1.1.xml {
        header Content-Type "application/xml"
        respond `<?xml version="1.0"?>
<clientConfig version="1.1">
  <emailProvider id="email-srvr.com">
    <displayName>Rackspace Email</displayName>
    <incomingServer type="imap">
      <hostname>mail.email-srvr.com</hostname>
      <port>993</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILADDRESS%</username>
    </incomingServer>
    <outgoingServer type="smtp">
      <hostname>mail.email-srvr.com</hostname>
      <port>465</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILADDRESS%</username>
    </outgoingServer>
  </emailProvider>
</clientConfig>` 200
    }
}