1 {pkgs, lib, config, ...}:
2 let inherit (builtins) attrNames;
3 inherit (config.services) dovecot2;
8 virtualHosts."autoconfig" =
9 let servers = lib.concatMapStringsSep " "
10 (dom: "autoconfig.${dom}")
11 (attrNames dovecot2.domains);
14 serverName = "autoconfig.${config.networking.domain}";
16 map (domainAlias: "autoconfig." + domainAlias)
17 config.networking.domainAliases;
23 root = pkgs.writeTextFile {
25 destination = "/mail/config-v1.1.xml";
28 <clientConfig version="1.1">
29 <emailProvider id="%EMAILDOMAIN%">
30 <!-- <displayName></displayName> -->
31 <!-- <displayShortName></displayShortName> -->
32 <domain>%EMAILDOMAIN%</domain>
33 <incomingServer type="imap">
34 <hostname>mail.%EMAILDOMAIN%</hostname>
36 <socketType>SSL</socketType>
37 <username>%EMAILADDRESS%</username>
38 <authentication>password-cleartext</authentication>
40 <incomingServer type="pop3">
41 <hostname>mail.%EMAILDOMAIN%</hostname>
43 <socketType>SSL</socketType>
44 <username>%EMAILADDRESS%</username>
45 <authentication>password-cleartext</authentication>
47 <leaveMessagesOnServer>false</leaveMessagesOnServer>
48 <downloadOnBiff>true</downloadOnBiff>
51 <outgoingServer type="smtp">
52 <hostname>mail.%EMAILDOMAIN%</hostname>
54 <socketType>SSL</socketType> <!-- see above -->
55 <username>%EMAILADDRESS%</username> <!-- if smtp-auth -->
56 <authentication>password-cleartext</authentication>
57 <!-- <restriction>client-IP-address</restriction> -->
58 <addThisServer>true</addThisServer>
59 <useGlobalPreferredServer>false</useGlobalPreferredServer>
62 <!-- <clientConfigUpdate url="https://www.example.com/config/mozilla.xml" /> -->