Code Examples
Replace YOUR_API_KEY with your actual key from the Overview page, and yourdomain.com with a domain you've verified.
curl -X POST https://api.altermail-console.com.ng/v1/user/email/send \
-H "Content-Type: application/json" \
-H "token: YOUR_API_KEY" \
-d '{
"email": "recipient@example.com",
"fromEmail": "hello@yourdomain.com",
"subject": "Hello from Altermail",
"mailBodyHtml": "<h1>Hello!</h1><p>This is a test email.</p>",
"mailBodyText": "Hello! This is a test email."
}'const response = await fetch("https://api.altermail-console.com.ng/v1/user/email/send", {
method: "POST",
headers: {
"Content-Type": "application/json",
"token": "YOUR_API_KEY",
},
body: JSON.stringify({
email: "recipient@example.com",
fromEmail: "hello@yourdomain.com",
subject: "Hello from Altermail",
mailBodyHtml: "<h1>Hello!</h1><p>This is a test email.</p>",
mailBodyText: "Hello! This is a test email.",
}),
});
const data = await response.json();
console.log(data);
// { Status: "Queued", messageId: "uuid", toEmail: "recipient@example.com", dkimSigned: true, quota: {...} }import requests
res = requests.post(
"https://api.altermail-console.com.ng/v1/user/email/send",
headers={
"Content-Type": "application/json",
"token": "YOUR_API_KEY",
},
json={
"email": "recipient@example.com",
"fromEmail": "hello@yourdomain.com",
"subject": "Hello from Altermail",
"mailBodyHtml": "<h1>Hello!</h1><p>This is a test email.</p>",
"mailBodyText": "Hello! This is a test email.",
},
)
print(res.status_code, res.json())<?php
$payload = json_encode([
"email" => "recipient@example.com",
"fromEmail" => "hello@yourdomain.com",
"subject" => "Hello from Altermail",
"mailBodyHtml" => "<h1>Hello!</h1><p>This is a test email.</p>",
"mailBodyText" => "Hello! This is a test email.",
]);
$ch = curl_init("https://api.altermail-console.com.ng/v1/user/email/send");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"token: YOUR_API_KEY",
],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
var_dump($response);package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"email": "recipient@example.com",
"fromEmail": "hello@yourdomain.com",
"subject": "Hello from Altermail",
"mailBodyHtml": "<h1>Hello!</h1><p>This is a test email.</p>",
"mailBodyText": "Hello! This is a test email.",
})
req, _ := http.NewRequest("POST", "https://api.altermail-console.com.ng/v1/user/email/send", bytes.NewBuffer(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("token", "YOUR_API_KEY")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(out))
}using System.Net.Http;
using System.Net.Http.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("token", "YOUR_API_KEY");
var payload = new {
email = "recipient@example.com",
fromEmail = "hello@yourdomain.com",
subject = "Hello from Altermail",
mailBodyHtml = "<h1>Hello!</h1><p>This is a test email.</p>",
mailBodyText = "Hello! This is a test email.",
};
var response = await client.PostAsJsonAsync("https://api.altermail-console.com.ng/v1/user/email/send", payload);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine((int)response.StatusCode + " " + result);import java.net.http.*;
import java.net.URI;
var body = """
{
"email": "recipient@example.com",
"fromEmail": "hello@yourdomain.com",
"subject": "Hello from Altermail",
"mailBodyHtml": "<h1>Hello!</h1><p>This is a test email.</p>",
"mailBodyText": "Hello! This is a test email."
}
""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.altermail-console.com.ng/v1/user/email/send"))
.header("Content-Type", "application/json")
.header("token", "YOUR_API_KEY")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());#include <curl/curl.h>
#include <string>
int main() {
CURL* curl = curl_easy_init();
if (!curl) return 1;
const std::string payload = R"({
"email": "recipient@example.com",
"fromEmail": "hello@yourdomain.com",
"subject": "Hello from Altermail",
"mailBodyHtml": "<h1>Hello!</h1><p>This is a test email.</p>",
"mailBodyText": "Hello! This is a test email."
})";
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "token: YOUR_API_KEY");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.altermail-console.com.ng/v1/user/email/send");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload.c_str());
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
// Compile: g++ -o send send.cpp -lcurl