Send an email using only JavaScript - no backend

Send an email using only JavaScript - no backend

While creating a lot of websites for small businesses I recognized the pain that only a single webserver will be used (based on costs) and at most HTML skills are available. But to provide a contact form, a backend solution and a mail server is necessary. Therefore I need an API based solution, which can be used via JavaScript, Angular, and so on...

In short:

1) Register for an API Key e.g. contact-mailer
2) Set Up your contact form
3) Use the API via Ajax call and a mail will be sent

How it works

Step 1
Sign up with your mail address, which will receive the mails:

Step 2
Copy the API Key

Step 3
Create your website containing your contact form, order process,....

Step 4
Write your own AJAX call, use the fetch API or use whatever library you prefer:

        const url = "";

        await fetch(url, {
          method: 'post',
          headers: {
            'Content-Type': 'application/json',
            'x-api-key': 'YOUR_API_KEY',
          body: JSON.stringify(
            "fromName": "Max Mustermann",
            "fromPhone": "0151987654321",
            "fromMail": "",
            "subject": "Reservierungsanfrage",
            "content": "Wir würden gerne nächste Woche einen Tisch bestellen: 25.03.2020 - 14:00 für 2 Personen"

That’s it! Now you can send emails using only JavaScript!

Note: The content can also contain HTML tables ;)

Keep in mind that your API key is visible to anyone, so any malicious user may use your key to send out emails. Therefore checkout the charts and statistics about your mail behavior.