The submit call sends a piece of text to a predefined email address. This is primarily useful to submit anonymous contact forms.
Submission forms are often publicly available. For that reason, a special account should be set up for each form. The key may be all zeros, since it has to be published anyway. 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. |
| 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.
If reply to is set to the special value "message", the reply-to address can be provided with the request.
Submits some text to a predefined destination. This is useful for contact forms which should be submitted to a predefined e-mail address. Create a separate account for each destination.
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(),
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 = '';
}
};