@@ -16,7 +16,24 @@ import ./make-test-python.nix {
1616 }
1717 ] ;
1818 } ;
19- environment . systemPackages = [ pkgs . opensmtpd ] ;
19+ environment . systemPackages = let
20+ testSendmail = pkgs . writeScriptBin "test-sendmail" ''
21+ #!/bin/sh
22+ set -euxo pipefail
23+ echo "========= SENDING" >&2
24+ ${ pkgs . system-sendmail } /bin/sendmail -v -f alice@smtp1 bob@smtp2 >&2 <<EOF
25+ From: alice@smtp1
26+ To: bob@smtp2
27+ Subject: Sendmail Test
28+
29+ Hello World
30+ EOF
31+ echo "=========== FINISHED SENDING" >&2
32+ '' ;
33+ in [
34+ pkgs . opensmtpd
35+ testSendmail
36+ ] ;
2037 services . opensmtpd = {
2138 enable = true ;
2239 extraServerArgs = [ "-v" ] ;
@@ -108,9 +125,12 @@ import ./make-test-python.nix {
108125 print("===> content:", content)
109126 split = content.split(b'\r\n')
110127 print("===> split:", split)
111- lastline = split[-3]
128+ split.reverse()
129+ lastline = next(filter(lambda x: x != b"", map(bytes.strip, split)))
112130 print("===> lastline:", lastline)
113131 assert lastline.strip() == b'Hello World'
132+ imap.store(refs[0], '+FLAGS', '\\Deleted')
133+ imap.expunge()
114134 '' ;
115135 in
116136 [
@@ -139,6 +159,11 @@ import ./make-test-python.nix {
139159 smtp1.wait_until_fails("smtpctl show queue | egrep .")
140160 smtp2.wait_until_fails("smtpctl show queue | egrep .")
141161 client.succeed("check-mail-landed >&2")
162+
163+ smtp1.succeed("test-sendmail")
164+ smtp1.wait_until_fails("smtpctl show queue | egrep .")
165+ smtp2.wait_until_fails("smtpctl show queue | egrep .")
166+ client.succeed("check-mail-landed >&2")
142167 '' ;
143168
144169 meta . timeout = 1800 ;
0 commit comments