Mailtarget Documentation

JavaScript

To integrate Mailtarget to your applications, websites, or systems with email functionality using JavaScript is easy.

Endpoints

All calls to the API need to start with the appropriate base URL:

Mailtarget productionhttps://transmission.mailtarget.co/v1

Implementation

Here's the basic code, copy and paste the JavaScript command below into your terminal, you can customize the content according to your needs.

VariableDescriptions
API_KEYAPI Key in dashboard
CURLOPT_URLhttps://transmission.mailtarget.co/v1/layang/transmissions
var myHeaders = new Headers(); myHeaders.append("accept", "application/json"); myHeaders.append("Content-Type", "application/json"); myHeaders.append("Authorization", "Bearer API_KEY"); var raw = JSON.stringify({ "bodyText": "Body Text", "bodyHtml": "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>Body HTML</title></head><body><p>Body HTML</p></body></html>", "from": { "email": "SENDER_EMAIL", "name": "SENDER_NAME" }, "subject": "Example email", "to": [ { "email": "RECIPIENT_EMAIL", "name": "RECIPIENT_NAME" } ] }); var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("https://transmission.mailtarget.co/v1/layang/transmissions", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));

Note :

  • API_KEY → change with API Key
  • SENDER_EMAIL → change with sender email
  • SENDER_NAME → change with sender name
  • RECIPIENT_EMAIL → change with recipient email
  • RECIPIENT_NAME → change with recipient name