1{ lib, ... }:
2{
3 name = "mailpit";
4 meta.maintainers = lib.teams.flyingcircus.members;
5
6 nodes.machine =
7 { pkgs, ... }:
8 {
9 services.mailpit.instances.default = { };
10
11 environment.systemPackages = with pkgs; [ swaks ];
12 };
13
14 testScript = ''
15 start_all()
16
17 from json import loads
18
19 machine.wait_for_unit("mailpit-default.service")
20 machine.wait_for_open_port(1025)
21 machine.wait_for_open_port(8025)
22 machine.succeed(
23 'echo "this is the body of the email" | swaks --to root@example.org --body - --server localhost:1025'
24 )
25
26 received = loads(machine.succeed("curl http://localhost:8025/api/v1/messages"))
27 assert received['total'] == 1
28 message = received["messages"][0]
29 assert len(message['To']) == 1
30 assert message['To'][0]['Address'] == 'root@example.org'
31 assert "this is the body of the email" in message['Snippet']
32 '';
33}