view src/index.html @ 1:6cd68fe047c7

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 19 May 2023 07:19:02 -0600
parents bd4802730bab
children 6cc785c26513
line wrap: on
line source

<!doctype html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<style>
			@import "/site.css";

			h1 {
				margin-bottom: 8px;
			}
			h4 {
				margin-top: 0;
			}

			textarea {
				width: 100%;
			}
			textarea[name=server] {
				height: 120px;
			}
			textarea[name=mail] {
				height: 260px;
			}
		</style>
		<script>
			let server = {
				host: 'mail.smtp2go.com',
				port: 587,
				username: 'luan.software',
				password: 'not telling',
			};
			server = JSON.stringify(server,null,'\t');

			let mails = {};

			mails.simple = {
				From: 'mailer@reactionary.software',
				To: 'someone@reactionary.software',
				Subject: 'Simple',
				body: 'Google sucks.',
			};

			mails.html = {
				From: 'mailer@reactionary.software',
				To: 'someone@reactionary.software',
				Subject: 'HTML',
				'Content-Type': 'multipart/alternative',
				body: [
					{
						'Content-Type': 'text/plain; charset="UTF-8"',
						body: 'Google sucks.',
					},
					{
						'Content-Type': 'text/html; charset="UTF-8"',
						body: '<a href="https://www.google.com/">Google</a> sucks.',
					},
				],
			};

			mails.attachment = {
				From: 'mailer@reactionary.software',
				To: 'someone@reactionary.software',
				Subject: 'Attachment',
				'Content-Type': 'multipart/mixed',
				body: [
					{
						'Content-Type': 'multipart/alternative',
						body: [
							{
								'Content-Type': 'text/plain; charset="UTF-8"',
								body: 'Google sucks.',
							},
							{
								'Content-Type': 'text/html; charset="UTF-8"',
								body: '<a href="https://www.google.com/">Google</a> sucks.',
							},
						],
					},
					{
						'Content-Disposition': 'attachment; filename="test.txt"',
						body: 'test file',
					},
				]
			};

			function set(what) {
				let s = JSON.stringify( mails[what], null, '\t' );
				document.querySelector('textarea[name=mail]').textContent = s;
			}

			function init() {
				document.querySelector('textarea[name=server]').textContent = server;
				set('simple');
			}
		</script>
		<title>Mailer REST API</title>
	</head>
	<body>
		<h1>Mailer REST API</h1>
		<h4><a href="http://www.reactionary.software/">Reactionary Software</a> by <a href="https://www.linkmystyle.com/fschmidt">fschmidt</a></h4>

		<p>Send emails by a POST request.</p>

		<form method=post action="/send.json">
			<p>
				SMTP Server<br>
				<textarea name=server></textarea><br>
				<small>Update to your server.</small>
			</p>
			<p>
				Mail<br>
				<textarea name=mail></textarea><br>
				<button type=button onclick="set('simple')">Simple</button>
				<button type=button onclick="set('html')">HTML</button>
				<button type=button onclick="set('attachment')">Attachment</button>
			</p>
			<p>
				<input type=submit>
			</p>
		</form>

		<p>Note that all <b>mail</b> fields except <b>body</b> are simply passed directly to SMTP.</p>

		<p>Here is <a href="https://hg.reactionary.software/repo/mailer/">the source</a> of this website.  This service is implemented in <a href="http://www.luan.software/">Luan</a>.  The entire implemention is in the file <a href="/send.json.luan">send.json.luan</a>.  And here are discussion threads on <a href="https://communities.win/c/programming/p/16b6N5KIjr/mailer-rest-api/c">Scored</a> and <a href="http://www.mikraite.org/Mailer-REST-API-tp3435.html">Reactionary Software</a> if you want to comment.</p>
	</body>
	<script> init(); </script>
</html>