PHP

This page provides an example of how to send an email using the NotifiedBy API in PHP.

<?php

$apiUrl = "https://api.notifiedby.com/v1/email/send/";

$data = [
    'recipient' => 'YOU@TESTEMAIL',
    'subject' => 'email from API',
    'body' => '<h1>Email from API</h1><p>This is an <strong>HTML</strong> email body.</p>',
    'plain_body' => 'This is the plain text version of the email body.'
];

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Api-Key YOUR_API_KEY'
]);

$response = curl_exec($ch);
curl_close($ch);


echo $response;

?>

Example with Encryption Key

<?php

$apiUrl = "https://api.notifiedby.com/v1/email/send/";

$data = [
    'recipient' => 'YOU@TESTEMAIL',
    'subject' => 'email from API',
    'body' => '<h1>Email from API</h1><p>This is an <strong>HTML</strong> email body.</p>',
    'plain_body' => 'This is the plain text version of the email body.'
];

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Api-Key YOUR_API_KEY',
    'Encryption-Key: my-encryption-key'
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

?>