2 certs = import ./common/acme/server/snakeoil-certs.nix;
5 import ./make-test-python.nix {
8 nodes.machine = { pkgs, ... }: {
9 imports = [ common/user-account.nix ];
12 enableSubmission = true;
13 enableSubmissions = true;
14 tlsTrustedAuthorities = "${certs.ca.cert}";
15 sslCert = "${certs.${domain}.cert}";
16 sslKey = "${certs.${domain}.key}";
17 submissionsOptions = {
18 smtpd_sasl_auth_enable = "yes";
19 smtpd_client_restrictions = "permit";
20 milter_macro_daemon_name = "ORIGINATING";
24 security.pki.certificateFiles = [
28 networking.extraHosts = ''
32 environment.systemPackages = let
33 sendTestMail = pkgs.writeScriptBin "send-testmail" ''
34 #!${pkgs.python3.interpreter}
37 with smtplib.SMTP('${domain}') as smtp:
38 smtp.sendmail('root@localhost', 'alice@localhost', 'Subject: Test\n\nTest data.')
42 sendTestMailStarttls = pkgs.writeScriptBin "send-testmail-starttls" ''
43 #!${pkgs.python3.interpreter}
47 ctx = ssl.create_default_context()
49 with smtplib.SMTP('${domain}') as smtp:
51 smtp.starttls(context=ctx)
53 smtp.sendmail('root@localhost', 'alice@localhost', 'Subject: Test STARTTLS\n\nTest data.')
57 sendTestMailSmtps = pkgs.writeScriptBin "send-testmail-smtps" ''
58 #!${pkgs.python3.interpreter}
62 ctx = ssl.create_default_context()
64 with smtplib.SMTP_SSL(host='${domain}', context=ctx) as smtp:
65 smtp.sendmail('root@localhost', 'alice@localhost', 'Subject: Test SMTPS\n\nTest data.')
68 in [ sendTestMail sendTestMailStarttls sendTestMailSmtps ];
72 machine.wait_for_unit("postfix.service")
73 machine.succeed("send-testmail")
74 machine.succeed("send-testmail-starttls")
75 machine.succeed("send-testmail-smtps")