${if lib.attrsets.hasAttr "withEmail" conf && lib.lists.length conf.withEmail > 0 then ''
mail IN A ${myconfig.env.servers.immaeEu.ips.main.ip4}
+ mx-1 IN A ${myconfig.env.servers.eldiron.ips.main.ip4}
${builtins.concatStringsSep "\n" (map (i: "mail IN AAAA ${i}") myconfig.env.servers.immaeEu.ips.main.ip6)}
+ ${builtins.concatStringsSep "\n" (map (i: "mx-1 IN AAAA ${i}") myconfig.env.servers.eldiron.ips.main.ip6)}
${lib.concatStringsSep "\n\n" (map (e:
let
n = if e.domain == "" then "@" else "${e.domain} ";
''
; ------------------ mail: ${n} ---------------------------
${if e.receive then "${n} IN MX 10 mail.${conf.name}." else ""}
+ ${if e.receive then "${n} IN MX 50 mx-1.${conf.name}." else ""}
; Mail sender authentications
${n} IN TXT "v=spf1 mx ~all"