The submit call sends a piece of text to a predefined email address. This is primarily useful to submit anonymous contact forms.
To send emails, you need to install a mail transfer agent (MTA) such as OpenSMTPD:
sudo apt install opensmtpd
Other supported MTAs are postfix and nullmailer.
You may also need to set up SPF/DKIM records for the envelope (Return-Path: ...
) and sender (From: ...
) addresses.
Submission forms are often publicly available. For that reason, a separate account should be set up for each form. The account must contain a submit section with the destination parameters:
The following destination parameters can be specified:
type | Must be "email" . Other values are reserved for future use. |
return path | The envelope sender address used in the SMTP MAIL FROM: command. If not set, the sender address is used. (optional) |
from | The sender address. |
to | A list of recipient addresses. |
cc | A list of carbon copy addresses. (optional) |
bcc | A list of hidden carbon copy addresses. (optional) |
reply to sender | If set to true, the contact form sender address is used as reply-to address. (optional) |
reply to | A reply-to address, if reply to sender is not set. (optional) |
subject | The subject. |
text | The plain text version of the email body. |
html | The HTML version of the email body. (optional) |
An address is written as follows:
whereby the name is optional.
In the subject and body, {property}
is replaced by the corresponding property value sent with the request.
Using Backend.js, a contact form (name, e-mail, message) can be submitted as follows:
const backend = new Backend('https://viereck.ch/backend'); const account = backend.account('your-account-id', '44705748... your-account-key'); sendButton.onclick = function(event) { const data = { sender: { name: name.value.trim(), email: email.value.trim() }, name: name.value.trim(), email: email.value.trim(), topic: topic.value.trim(), message: message.value.trim() }; account.submit(data, onDone, onError); function onDone(request) { successMessage.style.display = ''; sendButton.style.display = 'none'; } function onError(errorCode, request) { errorMessage.style.display = ''; } };
POST /backend/submit
Account: ACCOUNT ID
Timestamp: TIMESTAMP
Signature: SIGNATURE
200
if the data was submitted
400
if the request was invalid
401
if the account ID or signature is missing or invalid
403
if the account is not configured for submit calls