HTTP
Node.js
Python
PHP
Ruby
Go
Rust
Java
cURL
POST https://api.mx18.ai/v1/mail/send
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"from": { "email": "no-reply@yourdomain.com", "name": "Your App" },
"to": [{ "email": "user@example.com", "name": "Jane Doe" }],
"subject":"Welcome to Your App!",
"content":[{ "type":"text/plain", "value":"Hello, {{firstName}}!" }],
"personalizationData": { "firstName":"Jane" }
}
const axios = require("axios");
axios.post("https://api.mx18.ai/v1/mail/send", {
from: { email: "no-reply@yourdomain.com", name: "Your App" },
to: [{ email: "user@example.com", name: "Jane Doe" }],
subject: "Welcome to Your App!",
content: [{ type: "text/plain", value: "Hello, {{firstName}}!" }],
personalizationData: { firstName: "Jane" }
}, {
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
});
import requests
url = "https://api.mx18.ai/v1/mail/send"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"from": { "email": "no-reply@yourdomain.com", "name": "Your App" },
"to": [{ "email": "user@example.com", "name": "Jane Doe" }],
"subject": "Welcome to Your App!",
"content": [{ "type": "text/plain", "value": "Hello, {{firstName}}!" }],
"personalizationData": { "firstName": "Jane" }
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
<?php
$payload = json_encode([
"from" => [ "email" => "no-reply@yourdomain.com", "name" => "Your App" ],
"to" => [[ "email" => "user@example.com", "name" => "Jane Doe" ]],
"subject" => "Welcome to Your App!",
"content" => [[ "type" => "text/plain", "value" => "Hello, {{firstName}}!" ]],
"personalizationData" => [ "firstName" => "Jane" ]
]);
$ch = curl_init("https://api.mx18.ai/v1/mail/send");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("https://api.mx18.ai/v1/mail/send")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, {
"Authorization" => "Bearer YOUR_API_KEY",
"Content-Type" => "application/json"
})
request.body = {
from: { email: "no-reply@yourdomain.com", name: "Your App" },
to: [{ email: "user@example.com", name: "Jane Doe" }],
subject: "Welcome to Your App!",
content: [{ type: "text/plain", value: "Hello, {{firstName}}!" }],
personalizationData: { firstName: "Jane" }
}.to_json
response = http.request(request)
puts response.body
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload := map[string]interface{}{
"from": map[string]string{
"email": "no-reply@yourdomain.com", "name": "Your App",
},
"to": []map[string]string{
{"email": "user@example.com", "name": "Jane Doe"},
},
"subject": "Welcome to Your App!",
"content": []map[string]string{
{"type": "text/plain", "value": "Hello, {{firstName}}!"},
},
"personalizationData": map[string]string{"firstName": "Jane"},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.mx18.ai/v1/mail/send", bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println(resp.Status)
}
use reqwest::blocking::Client;
use serde_json::json;
fn main() {
let client = Client::new();
let res = client.post("https://api.mx18.ai/v1/mail/send")
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.json(&json!({
"from": { "email": "no-reply@yourdomain.com", "name": "Your App" },
"to": [{ "email": "user@example.com", "name": "Jane Doe" }],
"subject": "Welcome to Your App!",
"content": [{ "type": "text/plain", "value": "Hello, {{firstName}}!" }],
"personalizationData": { "firstName": "Jane" }
}))
.send()
.unwrap();
println!("{:?}", res.status());
}
import java.net.http.*;
import java.net.URI;
import java.net.http.HttpRequest.BodyPublishers;
public class MailSender {
public static void main(String[] args) throws Exception {
String json = """
{
"from": { "email": "no-reply@yourdomain.com", "name": "Your App" },
"to": [{ "email": "user@example.com", "name": "Jane Doe" }],
"subject": "Welcome to Your App!",
"content": [{ "type": "text/plain", "value": "Hello, {{firstName}}!" }],
"personalizationData": { "firstName": "Jane" }
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mx18.ai/v1/mail/send"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(json))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
curl -X POST https://api.mx18.ai/v1/mail/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": { "email": "no-reply@yourdomain.com", "name": "Your App" },
"to": [{ "email": "user@example.com", "name": "Jane Doe" }],
"subject":"Welcome to Your App!",
"content":[{ "type":"text/plain", "value":"Hello, {{firstName}}!" }],
"personalizationData": { "firstName":"Jane" }
}'