{ pkgs, ... }@all: with all;

{
  environment.systemPackages = with pkgs; [
    davmail
  ];

  services.davmail = {
    enable = true;
    url = "https://outlook.office365.com/EWS/Exchange.asmx";
    config = {
      davmail.server = true;
      davmail.mode = "Auto";
      davmail.defaultDomain = "phoenix-balkone.de";
      davmail.url = "https://outlook.office365.com/EWS/Exchange.asmx";
      davmail.ssl.nosecurecaldav = false;
      davmail.ssl.nosecureimap = false;
      davmail.ssl.nosecureldap = false;
      davmail.ssl.nosecuresmtp = false;
      davmail.imapPort = 60001;
      davmail.smtpPort = 60002;
      davmail.ldapPort = 60003;
      davmail.caldavPort = 60004;
      # davmail.popPort = ;
      davmail.allowRemote = false;
      davmail.bindAddress = "localhost";
      davmail.disableUpdateCheck = true;
      davmail.enableKeepAlive = true;
      davmail.folderSizeLimit = 999;
      davmail.imapAutoExpunge = true;
      davmail.imapIdleDelay = 10;
      davmail.keepDelay = 900;
      davmail.sentKeepDelay = 90;
      davmail.popMarkReadOnRetr = false;
      davmail.smtpSaveInSent = true;
      # davmail.logFilePath = "/var/log/davmail.log";
      davmail.logFileSize = "1MB";
      log4j.logger.davmail = "WARN";
      log4j.rootLogger = "WARN";
      davmail.disableGuiNotifications = false;
      davmail.disableTrayActivitySwitch = false;
      davmail.showStartupBanner = true;
      davmail.enableKerberos = false;
    };
  };
}
