113 lines
3.9 KiB
Plaintext
113 lines
3.9 KiB
Plaintext
# email_autodiscover - Dynamisches Autodiscover/Autoconfig Snippet
|
|
# Importiert im Caddyfile via: import email_autodiscover
|
|
#
|
|
# Funktioniert mit JEDER Domain automatisch, solange der Caddy-Block
|
|
# auf autodiscover.<domain> oder autoconfig.<domain> hört.
|
|
#
|
|
# Hostnames werden dynamisch abgeleitet:
|
|
# autodiscover.cielectrical.com → imap.cielectrical.com / smtp.cielectrical.com
|
|
# autoconfig.bayarea-cc.com → imap.bayarea-cc.com / smtp.bayarea-cc.com
|
|
#
|
|
# {labels.2}.{labels.1} extrahiert die Basisdomain aus dem Host:
|
|
# autodiscover.cielectrical.com → labels: [com=0, cielectrical=1, autodiscover=2]
|
|
# → {labels.1}.{labels.0} = cielectrical.com
|
|
|
|
(email_settings) {
|
|
# 1. Outlook Autodiscover (XML)
|
|
route /autodiscover/autodiscover.xml {
|
|
header Content-Type "application/xml"
|
|
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>imap.{labels.1}.{labels.0}</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>pop.{labels.1}.{labels.0}</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>smtp.{labels.1}.{labels.0}</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. Modern Outlook (JSON) - Redirect zum XML Endpoint
|
|
route /autodiscover/autodiscover.json {
|
|
header Content-Type "application/json"
|
|
respond `{
|
|
"Protocol": "AutodiscoverV1",
|
|
"Url": "https://autodiscover.{labels.1}.{labels.0}/autodiscover/autodiscover.xml"
|
|
}` 200
|
|
}
|
|
|
|
# 3. Thunderbird Autoconfig
|
|
route /mail/config-v1.1.xml {
|
|
header Content-Type "application/xml"
|
|
respond `<?xml version="1.0"?>
|
|
<clientConfig version="1.1">
|
|
<emailProvider id="{labels.1}.{labels.0}">
|
|
<displayName>{labels.1}.{labels.0} Mail</displayName>
|
|
<domain>{labels.1}.{labels.0}</domain>
|
|
<incomingServer type="imap">
|
|
<hostname>imap.{labels.1}.{labels.0}</hostname>
|
|
<port>993</port>
|
|
<socketType>SSL</socketType>
|
|
<authentication>password-cleartext</authentication>
|
|
<username>%EMAILADDRESS%</username>
|
|
</incomingServer>
|
|
<incomingServer type="pop3">
|
|
<hostname>pop.{labels.1}.{labels.0}</hostname>
|
|
<port>995</port>
|
|
<socketType>SSL</socketType>
|
|
<authentication>password-cleartext</authentication>
|
|
<username>%EMAILADDRESS%</username>
|
|
</incomingServer>
|
|
<outgoingServer type="smtp">
|
|
<hostname>smtp.{labels.1}.{labels.0}</hostname>
|
|
<port>465</port>
|
|
<socketType>SSL</socketType>
|
|
<authentication>password-cleartext</authentication>
|
|
<username>%EMAILADDRESS%</username>
|
|
</outgoingServer>
|
|
</emailProvider>
|
|
</clientConfig>` 200
|
|
}
|
|
|
|
# 4. Apple MobileConfig
|
|
route /apple {
|
|
templates {
|
|
mime "application/x-apple-aspen-config"
|
|
}
|
|
header Content-Type "application/x-apple-aspen-config; charset=utf-8"
|
|
root * /etc/caddy
|
|
rewrite * /email.mobileconfig.tpl
|
|
file_server
|
|
}
|
|
}
|