Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/mailhand/blob/main/tests/scenarios/70-smtp-tls.txt # mailhand mailhand: agents look after a person's email in seeded Omega. Maildir + MIME parsing, JSONL CLI and MCP, rule triage, policy-gated sending, hash-chained audit. Free (Apache-2.0). Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `mailhand / tests / scenarios / 70-smtp-tls.txt` 186 lines ยท 11038 bytes Raw Blame History 1 # SMTP submission over TLS (SmtpTls, src/ss.om) against the fake SMTP server "srv smtp" 2 # (tests/srv/smtp.om) over real TLS 1.3 (omtls from DEPS; host mail.test, the omtls test certificates). Config "smtp account:work" names the account whose smtp line 3 # is submission://HOST:587 (STARTTLS) or smtps://HOST:465 (implicit TLS). The send gate (policy, 4 # exact-draft approval, audit) is unchanged and runs before any connection; every failure before the 5 # TLS handshake completes aborts, so AUTH and MAIL never travel in plaintext (the server logs 6 # "PLAINTEXT AUTH" / "PLAINTEXT MAIL" if they ever did). Draft shas as in 30-send: plain `8ae0c21f`.., 7 # two `f995de68`... The TLS failure texts checked on stderr are omtls's (ot_tl_why). 8 mkdir @S/Mail 9 mkdir @S/c 10 run 0 - -- mh setup --home @S/h --maildir @S/Mail --me alice@example.org --name Alice 11 append @S/h/config smtp account:work\naccounts @S/c/accounts\n 12 copy tests/fixtures/send/plain.eml @S/h/drafts/`8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb`.eml 13 append @S/h/approvals `8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb` `1762862400`\n 14 run 0 - -- mh queue-send --home @S/h --draft `8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb` 15 out-has "gate":"approved" 16 # 17 # policy_refused_no_connection: the approval is withdrawn after queueing; deliver re-runs the gate, 18 # refuses, and the server (which fails if any connection arrives within 3 s) sees none 19 write @S/h/approvals \n 20 mkdir @S/k0 21 write @S/k0/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 22 bg srv smtp @S/k0 sub 0 23 run 0 - -- srv acct @S/c/accounts @S/k0 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 24 run 3 - -- mh deliver --home @S/h 25 out-has "op":"deliver","ok":false 26 wait 0 27 file-eq @S/k0/conns tests/fixtures/imap/zero.txt 28 absent @S/k0/log 29 append @S/h/approvals `8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb` `1762862400`\n 30 # 31 # no_starttls: the server does not offer STARTTLS: abort after the plaintext EHLO (exit 8, queued) 32 mkdir @S/k1 33 write @S/k1/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 34 bg srv smtp @S/k1 nostarttls 1 35 run 0 - -- srv acct @S/c/accounts @S/k1 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 36 run 8 - -- mh deliver --home @S/h 37 out-has "why":"smtp_failed" 38 err-has smtp: server does not offer STARTTLS: aborted before any credential or mail was sent 39 wait 0 40 file-not @S/k1/log AUTH 41 file-not @S/k1/log MAIL 42 exists @S/h/outbox/`8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb`.eml 43 # 44 # starttls_454: STARTTLS refused by the server: abort 45 mkdir @S/k2 46 write @S/k2/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 47 bg srv smtp @S/k2 tls454 1 48 run 0 - -- srv acct @S/c/accounts @S/k2 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 49 run 8 - -- mh deliver --home @S/h 50 err-has smtp: STARTTLS refused by the server: aborted before any credential or mail was sent 51 wait 0 52 file-not @S/k2/log AUTH 53 file-not @S/k2/log MAIL 54 # 55 # starttls_injection: plaintext bytes sent together with the "220" go-ahead are refused (they would 56 # be read as if they had come over TLS) 57 mkdir @S/k3 58 write @S/k3/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 59 bg srv smtp @S/k3 inject 1 60 run 0 - -- srv acct @S/c/accounts @S/k3 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 61 run 8 - -- mh deliver --home @S/h 62 err-has smtp: bytes arrived before the TLS handshake (refused) 63 wait 0 64 file-not @S/k3/log AUTH 65 file-not @S/k3/log MAIL 66 # 67 # plaintext_after_starttls: the server answers 220, then answers the ClientHello with a plaintext SMTP line: 68 # the handshake fails (unexpected message) and nothing more is sent 69 mkdir @S/k4 70 write @S/k4/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 71 bg srv smtp @S/k4 plainafter 1 72 run 0 - -- srv acct @S/c/accounts @S/k4 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 73 run 8 - -- mh deliver --home @S/h 74 err-has smtp: TLS: 75 err-has smtp: TLS: unexpected message 76 wait 0 77 file-not @S/k4/log AUTH 78 file-not @S/k4/log MAIL 79 # 80 # auth_refused: 535 after AUTH PLAIN over TLS: no MAIL, the draft stays queued 81 mkdir @S/k5 82 write @S/k5/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 83 bg srv smtp @S/k5 authfail 1 84 run 0 - -- srv acct @S/c/accounts @S/k5 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 85 run 8 - -- mh deliver --home @S/h 86 err-has smtp: authentication refused by the server 87 wait 0 88 file-has @S/k5/log TLS OK 89 file-has @S/k5/log AUTH REFUSED 90 file-not @S/k5/log PLAINTEXT 91 file-not @S/k5/log MAIL 92 # 93 # no_auth_plain: the server offers AUTH LOGIN only: abort 94 mkdir @S/k6 95 write @S/k6/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 96 bg srv smtp @S/k6 noplain 1 97 run 0 - -- srv acct @S/c/accounts @S/k6 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 98 run 8 - -- mh deliver --home @S/h 99 err-has smtp: server does not offer AUTH PLAIN 100 wait 0 101 file-not @S/k6/log AUTH 102 # 103 # refused handshakes (real TLS 1.3, omtls): another name (STARTTLS), expired (smtps), an untrusted root 104 # (STARTTLS). Each is a defined refusal (exit 8, the draft stays queued) with the omtls reason on 105 # stderr; the server log shows the TLS failure and no AUTH and no MAIL. 106 mkdir @S/q1 107 write @S/q1/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-other.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 108 bg srv smtp @S/q1 sub 1 109 run 0 - -- srv acct @S/c/accounts @S/q1 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 110 run 8 - -- mh deliver --home @S/h 111 err-has smtp: TLS: certificate does not match the host name 112 wait 0 113 file-has @S/q1/log TLS FAILED 114 file-not @S/q1/log AUTH 115 file-not @S/q1/log MAIL 116 exists @S/h/outbox/`8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb`.eml 117 mkdir @S/q2 118 write @S/q2/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-expired.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 119 bg srv smtp @S/q2 smtps 1 120 run 0 - -- srv acct @S/c/accounts @S/q2 work smtps mail.test alice@example.org s3cret-SYNTH-pw 600 121 run 8 - -- mh deliver --home @S/h 122 err-has smtp: TLS: certificate expired or not yet valid 123 wait 0 124 file-has @S/q2/log TLS FAILED 125 file-not @S/q2/log AUTH 126 file-not @S/q2/log MAIL 127 mkdir @S/q3 128 write @S/q3/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-untrusted.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 129 bg srv smtp @S/q3 sub 1 130 run 0 - -- srv acct @S/c/accounts @S/q3 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 131 run 8 - -- mh deliver --home @S/h 132 err-has smtp: TLS: certificate not issued by a trusted root 133 wait 0 134 file-has @S/q3/log TLS FAILED 135 file-not @S/q3/log AUTH 136 file-not @S/q3/log MAIL 137 # 138 # roots_missing: a trust store that cannot be loaded is refused before any connection (the server, 139 # which fails when any connection arrives within 3 s, sees none) 140 mkdir @S/q4 141 write @S/q4/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @S/no-such-roots.pem\n 142 bg srv smtp @S/q4 sub 0 143 run 0 - -- srv acct @S/c/accounts @S/q4 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 144 run 8 - -- mh deliver --home @S/h 145 err-has smtp: trust store could not be loaded 146 wait 0 147 file-eq @S/q4/conns tests/fixtures/imap/zero.txt 148 # 149 # starttls_sent: STARTTLS, EHLO again, AUTH PLAIN over TLS, then the exact draft bytes are delivered 150 mkdir @S/k7 151 write @S/k7/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 152 bg srv smtp @S/k7 sub 1 153 run 0 - -- srv acct @S/c/accounts @S/k7 work submission mail.test alice@example.org s3cret-SYNTH-pw 600 154 run 0 - -- mh deliver --home @S/h 155 out-has "op":"deliver","ok":true,"why":"sent" 156 out-not s3cret 157 err-not s3cret 158 wait 0 159 file-eq @S/k7/1.eml tests/fixtures/send/plain.eml 160 file-has @S/k7/1.env RCPT TO: 161 file-has @S/k7/log TLS OK 162 file-has @S/k7/log AUTH OK 163 file-has @S/k7/log MAIL FROM: 164 file-not @S/k7/log PLAINTEXT 165 absent @S/h/outbox/`8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb`.eml 166 # 167 # smtps_sent: implicit TLS on the smtps endpoint; both recipients 168 copy tests/fixtures/send/two.eml @S/h/drafts/`f995de6838541f4cd3029a1d238c09f89a00468c71f973ee74a6fc54af6c7464`.eml 169 append @S/h/approvals `f995de6838541f4cd3029a1d238c09f89a00468c71f973ee74a6fc54af6c7464` `1762862400`\n 170 run 0 - -- mh queue-send --home @S/h --draft `f995de6838541f4cd3029a1d238c09f89a00468c71f973ee74a6fc54af6c7464` 171 mkdir @S/k8 172 write @S/k8/state user alice@example.org\npass s3cret-SYNTH-pw\nchain @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-good.der\nkey @R/build/deps/omtlsfix/tests/fixtures/srv/leaf-key.txt\nroots @R/build/deps/omtlsfix/tests/fixtures/srv/root.pem\n 173 bg srv smtp @S/k8 smtps 1 174 run 0 - -- srv acct @S/c/accounts @S/k8 work smtps mail.test alice@example.org s3cret-SYNTH-pw 600 175 run 0 - -- mh deliver --home @S/h 176 out-has "why":"sent" 177 wait 0 178 file-eq @S/k8/1.eml tests/fixtures/send/two.eml 179 file-has @S/k8/log TLS OK 180 file-not @S/k8/log PLAINTEXT 181 # 182 # credential_leak_scan: no password and no AUTH PLAIN blob in anything mailhand wrote 183 tree-not @S/h s3cret-SYNTH-pw 184 tree-not @S/h AGFsaWNlQGV4YW1wbGUub3JnAHMzY3JldC1TWU5USC1wdw== 185 tree-not @S/Mail s3cret-SYNTH-pw 186 file-has @S/h/sent.log `8ae0c21f05999c8c000e58d5ff61706fad52a733e8860684c3bb43c2521f88fb`