{ vhack, packageSets, ownName, ... }: let pkgs = packageSets.stable; domain = "mail.server.test"; common = import ../../../common/email/functions.nix { inherit pkgs; vhackPackages = packageSets.in_tree; }; in vhack.runTest { name = ownName; serverDomains = [ {server = domain;} ]; nodes = { server = {config, ...}: { systemd.tmpfiles.rules = [ #- path mode user group - content "f /passwords/alice 777 root root - alice-password" "f /passwords/bob 777 root root - bob-password" ]; vhack = { mail = { enable = true; fqdn = domain; domains = [ domain ]; accounts = { "alice@${domain}" = { passwordFile = "/passwords/alice"; }; "bob@${domain}" = { passwordFile = "/passwords/bob"; }; }; }; }; }; alice = common.mkUser "alice" domain; bob = common.mkUser "bob" domain; }; services = [ {server = "postfix.service";} ]; ports = [ {server = 993;} # imap {server = 465;} # smtp ]; testScript = {...}: # Python '' with subtest("Both start without mail"): alice.succeed("sudo -u alice ${common.scripts.expectNoNewMail}") bob.succeed("sudo -u bob ${common.scripts.expectNoNewMail}") with subtest("Alice can send an email to bob"): alice.succeed("sudo -u alice ${pkgs.writeShellScript "alice-send" '' set -xe cat << EOF | msmtp --debug --account alice bob@${domain} >&2 Hi Bob! This is an email. It contains a subject and a body. ALICE EOF ''}") # TODO: Find a better way to wait until alice mail has finished going through the # email queue <2026-11-26> from time import sleep sleep(2) bob.succeed("sudo -u bob ${common.scripts.expectNewMail}") ''; }