1 import ./make-test-python.nix ({ pkgs, ... }: {
3 meta = with pkgs.lib.maintainers; { maintainers = [ onny ]; };
10 primaryDomain = "server";
16 environment.systemPackages = [
17 (pkgs.writers.writePython3Bin "send-testmail" { } ''
19 from email.mime.text import MIMEText
21 msg = MIMEText("Hello World")
22 msg['Subject'] = 'Test'
23 msg['From'] = "postmaster@server"
24 msg['To'] = "postmaster@server"
25 with smtplib.SMTP('server', 587) as smtp:
26 smtp.login('postmaster@server', 'test')
27 smtp.sendmail('postmaster@server', 'postmaster@server', msg.as_string())
29 (pkgs.writers.writePython3Bin "test-imap" { } ''
32 with imaplib.IMAP4('server') as imap:
33 imap.login('postmaster@server', 'test')
35 status, refs = imap.search(None, 'ALL')
38 status, msg = imap.fetch(refs[0], 'BODY[TEXT]')
40 assert msg[0][1].strip() == b"Hello World"
48 server.wait_for_unit("maddy.service")
49 server.wait_for_open_port(143)
50 server.wait_for_open_port(587)
52 server.succeed("maddyctl creds create --password test postmaster@server")
53 server.succeed("maddyctl imap-acct create postmaster@server")
55 client.succeed("send-testmail")
56 client.succeed("test-imap")