1import ./make-test-python.nix ({ lib, ... }:
2
3{
4 name = "mailcatcher";
5 meta.maintainers = [ lib.maintainers.aanderse ];
6
7 nodes.machine =
8 { pkgs, ... }:
9 {
10 services.mailcatcher.enable = true;
11
12 programs.msmtp = {
13 enable = true;
14 accounts.default = {
15 host = "localhost";
16 port = 1025;
17 };
18 };
19
20 environment.systemPackages = [ pkgs.mailutils ];
21 };
22
23 testScript = ''
24 start_all()
25
26 machine.wait_for_unit("mailcatcher.service")
27 machine.wait_for_open_port(1025)
28 machine.succeed(
29 'echo "this is the body of the email" | mail -s "subject" root@example.org'
30 )
31 assert "this is the body of the email" in machine.succeed(
32 "curl -f http://localhost:1080/messages/1.source"
33 )
34 '';
35})