9 cfg = config.services.mailcatcher;
24 services.mailcatcher = {
25 enable = mkEnableOption "MailCatcher, an SMTP server and web interface to locally test outbound emails";
29 default = "127.0.0.1";
30 description = "The ip address of the http server.";
33 http.port = mkOption {
36 description = "The port address of the http server.";
39 http.path = mkOption {
40 type = with types; nullOr str;
42 description = "Prefix to all HTTP paths.";
43 example = "/mailcatcher";
48 default = "127.0.0.1";
49 description = "The ip address of the smtp server.";
52 smtp.port = mkOption {
55 description = "The port address of the smtp server.";
63 config = mkIf cfg.enable {
64 environment.systemPackages = [ pkgs.mailcatcher ];
66 systemd.services.mailcatcher = {
67 description = "MailCatcher Service";
68 after = [ "network.target" ];
69 wantedBy = [ "multi-user.target" ];
75 "${pkgs.mailcatcher}/bin/mailcatcher --foreground --no-quit --http-ip ${cfg.http.ip} --http-port ${toString cfg.http.port} --smtp-ip ${cfg.smtp.ip} --smtp-port ${toString cfg.smtp.port}"
76 + optionalString (cfg.http.path != null) " --http-path ${cfg.http.path}";
77 AmbientCapabilities = optionalString (
78 cfg.http.port < 1024 || cfg.smtp.port < 1024
79 ) "cap_net_bind_service";