Sending E-Mails

The sendmail request allows to send arbitrary e-mails.

Since this is effectively an open e-mail gateway, this must only be used in places where the end user can be identified. For anonymous contact forms, use submit requests.

Account configuration

To use sendmail, an account must have the sendmail flag:

{"candy/paul": {"key": "...", "sendmail": true, "...": null}, "candy/margrit": {"key": "...", "sendmail": true, "...": null}, "...": null}

Every end user should be given a separate account to track abuse.

HTTP/REST Requests

POST /backend/sendmail
Account: ACCOUNT ID
Timestamp: TIMESTAMP
Signature: SIGNATURE
MAIL

Sends an e-mail using the server's sendmail program. The MAIL text must be a properly formatted MIME message.

Response

  • 200
  • 400, if the request was invalid
  • 401, if the account ID or signature is missing or invalid
  • 403, if the account is not allowed to use SVG to PDF
Account ID
Account key
MIME encoded e-mail

JavaScript

Using Backend.js, a mail can be sent as follows:

const backend = new Backend('https://viereck.ch/backend');
const account = backend.account('your-account-id', '44705748... your-account-key');

const mail = `From: ali@some-domain.com
To: oskar@some-domain.com
Subject: Hello

This is a test email.`;

account.sendmail(mail, onDone, onError);

function onDone(request) {
	...
}

function onError(errorCode, request) {
	...
}