comparison src/private/tools/email.html @ 0:8f4df159f06b

start public repo
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 11 Jul 2025 20:57:49 -0600
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8f4df159f06b
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta name="viewport" content="width=device-width, initial-scale=1">
5 <style>
6 @import "/tools/tools.css";
7
8 body {
9 margin: 3%;
10 }
11 textarea {
12 width: 100%;
13 }
14 textarea[name=server] {
15 height: 130px;
16 }
17 textarea[name=mail] {
18 height: 260px;
19 }
20 </style>
21 <script>
22 let mails = {};
23
24 mails.chatty_text = `
25 {
26 To = "ftest@linkmy.style"
27 From = "Link My Style <support@linkmy.style>"
28 Subject = "checking in"
29 ["MIME-Version"] = "1.0"
30 body = [[
31 Hi there,
32
33 just checking if this email reaches you.
34
35 Have a great day.
36
37 mlrch-6c2977f34d1e0
38 ]]
39 }
40 ` .trim();
41
42 mails.chatty_multipart = `
43 {
44 To = "ftest@linkmy.style"
45 From = "Link My Style <support@linkmy.style>"
46 Subject = "checking in"
47 ["MIME-Version"] = "1.0"
48 ["Content-Type"] = "multipart/alternative"
49 body = {
50 {
51 ["Content-Type"] = [[text/plain; charset="UTF-8"]]
52 body = [[
53 Hi there,
54
55 just checking if this email reaches you.
56
57 Have a great day.
58 ]]
59 }
60 {
61 ["Content-Type"] = [[text/html; charset="UTF-8"]]
62 body = [[
63 Hi there,<br>
64 <br>
65 just checking if this email reaches you.<br>
66 <br mailreach="mlrch-6c2977f34d1e0">
67 Have a great day.<br>
68 ]]
69 }
70 }
71 }
72 ` .trim();
73
74 mails.register_text = `
75 {
76 To = "ftest@linkmy.style"
77 From = "Link My Style <support@linkmy.style>"
78 Subject = "Confirmation Code"
79 ["MIME-Version"] = "1.0"
80 body = [[
81 Thank you for registering. Please use the 6 digit confirmation code below to complete the process:
82
83 Confirmation Code: 999999
84
85 If you did not request this code, please ignore this email.
86
87 mlrch-6c2977f34d1e0
88 ]]
89 }
90 ` .trim();
91
92 mails.register_multipart = `
93 {
94 To = "ftest@linkmy.style"
95 From = "Link My Style <support@linkmy.style>"
96 Subject = "Confirmation Code"
97 ["MIME-Version"] = "1.0"
98 ["Content-Type"] = "multipart/alternative"
99 body = {
100 {
101 ["Content-Type"] = [[text/plain; charset="UTF-8"]]
102 body = [[
103 Thank you for registering. Please use the 6 digit confirmation code below to complete the process:
104
105 Confirmation Code: 999999
106
107 If you did not request this code, please ignore this email.
108 ]]
109 }
110 {
111 ["Content-Type"] = [[text/html; charset="UTF-8"]]
112 body = [[
113 Thank you for registering. Please use the 6 digit confirmation code below to complete the process:<br>
114 <br>
115 Confirmation Code: <b>999999</b><br>
116 <br mailreach="mlrch-6c2977f34d1e0">
117 If you did not request this code, please ignore this email.<br>
118 ]]
119 }
120 }
121 }
122 ` .trim();
123
124 function set(what) {
125 document.querySelector('textarea[name=mail]').value = mails[what];
126 }
127 </script>
128 <title>Test Email</title>
129 </head>
130 <body>
131 <h1>Test Email</h1>
132
133 <form method=post action="send_email.txt">
134 <p>
135 SMTP Server<br>
136 <textarea name=server>
137 {
138 host = "smtpcorp.com"
139 port = 465
140 username = "linkmystyle"
141 password = "xxx"
142 }
143 </textarea>
144 </p>
145 <p>
146 Mail<br>
147 <textarea name=mail></textarea><br>
148 <button type=button onclick="set('chatty_text')">chatty_text</button>
149 <button type=button onclick="set('chatty_multipart')">chatty_multipart</button>
150 <button type=button onclick="set('register_text')">register_text</button>
151 <button type=button onclick="set('register_multipart')">register_multipart</button>
152 </p>
153 <p>
154 <input type=submit>
155 </p>
156 </form>
157
158 <p>The textareas contain <a href="https://www.luan.software/">Luan</a> tables which is more convenient than JSON. Table keys can be like <b>key</b> when the key is like a variable name, or like <b>["a-key"]</b> when the key contains characters that aren't allowed in variable names. String values can be like <b>"..."</b> or like <b>[[...]]</b> which can be multi-line.</b>
159
160 <p>Change the server password to make this work</p>
161
162 <p>Note that all mail fields except <b>body</b> are simply passed directly to SMTP.</p>
163 </body>
164 <script> set('register_multipart'); </script>
165 </html>