Skip to main content

Legacy Send Email API (PHP Example)

Marcel Ursprung avatar
Written by Marcel Ursprung
Updated over a month ago

This API is deprecated and supported only for existing integrations.

Use the modern send API instead.

Authentication

You need to use your API ID and Auth Key as username / password. You can find this under the Integrations tab of the Account Settings page in your account.

Message content

You can't send an email by providing a template or message ID to the API. You need to supply the raw HTML to the API using the message_html field.

$username = "";
$password = "";

$html = '<p>Hello world!</p>';

$data = [
'SendEmails' => [
[
'EmailDataArray' => [
[
'email' => [
// Message fields...
[
"to_email" => "",
"to_name" => "",
"from_email" => "",
"from_name" => "",
"message_subject" => "",
"message_html" => $html,
]
]
]
]
]
]
];

$request_data = json_encode($data);
$content_type = "application/json";

$url = 'https://e1.envoke.com/api/v4legacy/send/SendEmails';

$curl = curl_init();

curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($curl, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request_data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: ' . $content_type . '; charset=utf-8' ]);
curl_setopt($curl, CURLOPT_URL, $url);

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

echo $response;

Did this answer your question?