1{ lib, ... }:
2{
3 name = "mailhog";
4 meta.maintainers = with lib.maintainers; [
5 jojosch
6 RTUnreal
7 ];
8
9 nodes.machine = _: {
10 services.mailhog.enable = true;
11 };
12
13 testScript = ''
14 start_all()
15
16 machine.wait_for_unit("mailhog.service")
17 machine.wait_for_open_port(1025)
18 machine.wait_for_open_port(8025)
19 # Test sendmail wrapper (this uses smtp, which tests the connection)
20 machine.succeed('printf "To: root@example.com\r\n\r\nthis is the body of the email" | sendmail -t -i -f sender@example.com')
21 res = machine.succeed(
22 "curl --fail http://localhost:8025/api/v2/messages"
23 )
24 assert all(msg in res for msg in ["this is the body of the email", "sender@example.com", "root@example.com"])
25 '';
26}