[Unit] Description=maddy mail server (using %i.conf) Documentation=man:maddy(1) Documentation=man:maddy.conf(5) Documentation=https://maddy.email After=network.target [Service] Type=notify NotifyAccess=main User=maddy Group=maddy ConfigurationDirectory=maddy RuntimeDirectory=maddy StateDirectory=maddy LogsDirectory=maddy ReadOnlyPaths=/usr/lib/maddy ReadWritePaths=/var/lib/maddy # Strict sandboxing. You have no reason to trust code written by strangers from GitHub. PrivateTmp=true PrivateHome=true ProtectSystem=strict ProtectKernelTunables=true ProtectHostname=true ProtectClock=true ProtectControlGroups=true RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 DeviceAllow=/dev/syslog # Additional sandboxing. You need to disable all of these options # for privileged helper binaries (for system auth) to work correctly. NoNewPrivileges=true PrivateDevices=true RestrictSUIDSGID=true ProtectKernelModules=true MemoryDenyWriteExecute=true RestrictNamespaces=true RestrictRealtime=true LockPersonality=true # Graceful shutdown with a reasonable timeout. TimeoutStopSec=7s KillMode=mixed KillSignal=SIGTERM # Required to bind on ports lower than 1024. AmbientCapabilities=CAP_NET_BIND_SERVICE CapabilityBoundingSet=CAP_NET_BIND_SERVICE # Force all files created by maddy to be only readable by it. UMask=0027 # Bump FD limitations. Even idle mail server can have a lot of FDs open (think # of idle IMAP connections, especially ones abandoned on the other end and # slowly timing out). LimitNOFILE=131072 # Limit processes count to something reasonable to # prevent resources exhausting due to big amounts of helper # processes launched. LimitNPROC=512 # Restart server on any problem. Restart=on-failure # ... Unless it is a configuration problem. RestartPreventExitStatus=2 ExecStart=/usr/local/bin/maddy --config /etc/maddy/%i.conf run ExecReload=/bin/kill -USR1 $MAINPID ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target