Send email
Send email through API
POST
https://api.mailhub.sh/v1/send
Headers
Body
Example
curl -X POST "https://api.mailhub.sh/v1/send" \
--header "Authorization: Bearer <<YOUR_API_KEY_HERE>>" \
--header "Content-Type: application/json" \
--data '{
"layout_identifier": "<<YOUR_LAYOUT_ID>>",
"variables": {},
"code": null,
"from": "Example <example@your-domain.com>",
"to": "example@mailhub.sh",
"subject": "hello world",
...
}'
fetch(`https://api.mailhub.sh/v1/send`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer <<YOUR_API_KEY_HERE>>',
},
body: JSON.stringify({
layout_identifier: '<<YOUR_LAYOUT_ID>>',
variables: {},
code: null,
from: 'Example <example@your-domain.com>',
to: 'example@mailhub.sh',
subject: 'hello world',
...
}),
})
.then((data) => {
console.log(data);
})
.catch((error) => {
console.error('Error:', error);
});
var message = new
{
layout_identifier = "<<YOUR_LAYOUT_ID>>",
variables = new { },
from = "Example <example@your-domain.com>",
to = "example@mailhub.sh",
subject = "hello world"
};
RestClient client = new RestClient();
RestRequest request = new RestRequest("https://api.mailhub.sh/v1/send", Method.Post);
request.AddHeader("Authorization", $"Bearer <<YOUR_API_KEY_HERE>>");
request.AddJsonBody(msg, "application/json");
var response = client.Execute(request);
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$url = "https://api.mailhub.sh/v1/send";
$data = [
'layout_identifier' => '<<YOUR_LAYOUT_ID>>',
'variables' => [],
'code' => null,
'from' => 'Example <example@your-domain.com>',
'to' => 'example@mailhub.sh',
'subject' => 'hello world'
];
$headers = [
"Content-Type" => "application/json",
"Authorization" => "Bearer <<YOUR_API_KEY_HERE>>"
];
try {
$response = $client->post($url, [
'headers' => $headers,
'json' => $data
]);
$responseBody = $response->getBody();
$decodedResponse = json_decode($responseBody, true);
print_r($decodedResponse);
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
Last updated