Stalwart: Difference between revisions

From NixOS Wiki
imported>Onny
Add see also section
Onny (talk | contribs)
(3 intermediate revisions by 3 users not shown)
Line 2: Line 2:


== Setup ==
== Setup ==
 
The following minimal configuration example is unsecure and for testing purpose only. It will run the Stalwart mail server on <code>localhost</code>, listening on port <code>143</code> (IMAP) and <code>587</code> (Submission). Users <code>alice</code> and <code>bob</code> are configured with the password <code>foobar</code>.{{file|/etc/nixos/configuration.nix|nix|3=services.stalwart-mail = {
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
services.stalwart-mail = {
   enable = true;
   enable = true;
  # Use newer, latest version in NixOS 24.05
  package = pkgs.stalwart-mail;
   settings = {
   settings = {
    certificate."snakeoil" = {
      cert = "file://${certs.${domain}.cert}";
      private-key = "file://${certs.${domain}.key}";
    };
     server = {
     server = {
       hostname = domain;
       hostname = "localhost";
       tls = {
       tls.enable = false;
        certificate = "snakeoil";
        enable = true;
        implicit = false;
      };
       listener = {
       listener = {
         "smtp-submission" = {
         "smtp-submission" = {
Line 28: Line 20:
         };
         };
       };
       };
      session = {
    };
        rcpt.directory = "in-memory";
    imap.auth.allow-plain-text = true;
        auth = {
    session.auth = {
          mechanisms = [ "PLAIN" ];
      mechanisms = "[plain, auth]";
          directory = "in-memory";
      directory = "'in-memory'";
        };
    };
      };
    storage.directory = "in-memory";
      jmap.directory = "in-memory";
    session.rcpt.directory = "'in-memory'";
      queue.outbound.next-hop = [ "local" ];
    queue.outbound.next-hop = "'local'";
      directory."in-memory" = {
    directory."in-memory" = {
        type = "memory";
      type = "memory";
        users = [
      principals = [
           {
        {
            name = "alice";
           class = "individual";
            secret = "foobar";
          name = "alice";
            email = [ "alice@${domain}" ];
          secret = "foobar";
          }
          email = [ "alice@localhost" ];
           {
        }
            name = "bob";
        {
            secret = "foobar";
           class = "individual";
            email = [ "bob@${domain}" ];
          name = "bob";
          }
          secret = "foobar";
        ];
          email = [ "bob@$localhost" ];
      };
        }
      ];
     };
     };
   };
   };
};
};}}
</nowiki>}}


== See also ==
== See also ==
Line 64: Line 56:


[[Category:Mail Server]]
[[Category:Mail Server]]
[[Category:Server]]

Revision as of 12:47, 28 June 2024

Stalwart is an open-source, all-in-one mail server solution that supports JMAP, IMAP4, and SMTP protocols. It's designed to be secure, fast, robust, and scalable, with features like built-in DMARC, DKIM, SPF, and ARC support for message authentication. It also provides strong transport security through DANE, MTA-STS, and SMTP TLS reporting. Stalwart is written in Rust, ensuring high performance and memory safety.

Setup

The following minimal configuration example is unsecure and for testing purpose only. It will run the Stalwart mail server on localhost, listening on port 143 (IMAP) and 587 (Submission). Users alice and bob are configured with the password foobar.

/etc/nixos/configuration.nix
services.stalwart-mail = {
  enable = true;
  # Use newer, latest version in NixOS 24.05
  package = pkgs.stalwart-mail;
  settings = {
    server = {
      hostname = "localhost";
      tls.enable = false;
      listener = {
        "smtp-submission" = {
          bind = [ "[::]:587" ];
          protocol = "smtp";
        };
        "imap" = {
          bind = [ "[::]:143" ];
          protocol = "imap";
        };
      };
    };
    imap.auth.allow-plain-text = true;
    session.auth = {
      mechanisms = "[plain, auth]";
      directory = "'in-memory'";
    };
    storage.directory = "in-memory";
    session.rcpt.directory = "'in-memory'";
    queue.outbound.next-hop = "'local'";
    directory."in-memory" = {
      type = "memory";
      principals = [
        {
          class = "individual";
          name = "alice";
          secret = "foobar";
          email = [ "alice@localhost" ];
        }
        {
          class = "individual";
          name = "bob";
          secret = "foobar";
          email = [ "bob@$localhost" ];
        }
      ];
    };
  };
};

See also