view src/index.html @ 6:9aebae0306b1

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 15 Sep 2024 07:42:57 -0600
parents 2e211bec24d7
children ecc665c507b5
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: 465,
				username: 'reactionary',
				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://linkmy.style/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>Port 465 uses SSL.  Other ports are unencrypted.  If anyone can give me good reason why TLS or STARTTLS are needed, I can implement them.</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 is <a href="https://mikraite.arkian.net/Mailer-REST-API-tp3435.html">a discussion thread</a> if you want to comment.</p>
	</body>
	<script> init(); </script>
</html>