Mercurial Hosting > linkmystyle
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/private/tools/email.html Fri Jul 11 20:57:49 2025 -0600 @@ -0,0 +1,165 @@ +<!doctype html> +<html lang="en"> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style> + @import "/tools/tools.css"; + + body { + margin: 3%; + } + textarea { + width: 100%; + } + textarea[name=server] { + height: 130px; + } + textarea[name=mail] { + height: 260px; + } + </style> + <script> + let mails = {}; + + mails.chatty_text = ` +{ + To = "ftest@linkmy.style" + From = "Link My Style <support@linkmy.style>" + Subject = "checking in" + ["MIME-Version"] = "1.0" + body = [[ +Hi there, + +just checking if this email reaches you. + +Have a great day. + +mlrch-6c2977f34d1e0 +]] +} +` .trim(); + + mails.chatty_multipart = ` +{ + To = "ftest@linkmy.style" + From = "Link My Style <support@linkmy.style>" + Subject = "checking in" + ["MIME-Version"] = "1.0" + ["Content-Type"] = "multipart/alternative" + body = { + { + ["Content-Type"] = [[text/plain; charset="UTF-8"]] + body = [[ +Hi there, + +just checking if this email reaches you. + +Have a great day. +]] + } + { + ["Content-Type"] = [[text/html; charset="UTF-8"]] + body = [[ +Hi there,<br> +<br> +just checking if this email reaches you.<br> +<br mailreach="mlrch-6c2977f34d1e0"> +Have a great day.<br> +]] + } + } +} +` .trim(); + + mails.register_text = ` +{ + To = "ftest@linkmy.style" + From = "Link My Style <support@linkmy.style>" + Subject = "Confirmation Code" + ["MIME-Version"] = "1.0" + body = [[ +Thank you for registering. Please use the 6 digit confirmation code below to complete the process: + +Confirmation Code: 999999 + +If you did not request this code, please ignore this email. + +mlrch-6c2977f34d1e0 +]] +} +` .trim(); + + mails.register_multipart = ` +{ + To = "ftest@linkmy.style" + From = "Link My Style <support@linkmy.style>" + Subject = "Confirmation Code" + ["MIME-Version"] = "1.0" + ["Content-Type"] = "multipart/alternative" + body = { + { + ["Content-Type"] = [[text/plain; charset="UTF-8"]] + body = [[ +Thank you for registering. Please use the 6 digit confirmation code below to complete the process: + +Confirmation Code: 999999 + +If you did not request this code, please ignore this email. +]] + } + { + ["Content-Type"] = [[text/html; charset="UTF-8"]] + body = [[ +Thank you for registering. Please use the 6 digit confirmation code below to complete the process:<br> +<br> +Confirmation Code: <b>999999</b><br> +<br mailreach="mlrch-6c2977f34d1e0"> +If you did not request this code, please ignore this email.<br> +]] + } + } +} +` .trim(); + + function set(what) { + document.querySelector('textarea[name=mail]').value = mails[what]; + } + </script> + <title>Test Email</title> + </head> + <body> + <h1>Test Email</h1> + + <form method=post action="send_email.txt"> + <p> + SMTP Server<br> + <textarea name=server> +{ + host = "smtpcorp.com" + port = 465 + username = "linkmystyle" + password = "xxx" +} +</textarea> + </p> + <p> + Mail<br> + <textarea name=mail></textarea><br> + <button type=button onclick="set('chatty_text')">chatty_text</button> + <button type=button onclick="set('chatty_multipart')">chatty_multipart</button> + <button type=button onclick="set('register_text')">register_text</button> + <button type=button onclick="set('register_multipart')">register_multipart</button> + </p> + <p> + <input type=submit> + </p> + </form> + + <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> + + <p>Change the server password to make this work</p> + + <p>Note that all mail fields except <b>body</b> are simply passed directly to SMTP.</p> + </body> + <script> set('register_multipart'); </script> +</html>