PHP Quickstart
<?php
$ch = curl_init('https://apis.splashifypro.com/api/v1/partner/email/send');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SPLASHIFY_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'from' => 'hello@yourcompany.com',
'to' => ['customer@example.com'],
'subject' => 'Welcome',
'html_body' => '<h1>Welcome 👋</h1>',
'text_body' => 'Welcome.',
]),
]);
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$body = json_decode($res, true);
if ($status >= 400) {
throw new RuntimeException($body['error'] . ': ' . $body['message']);
}
echo $body['results'][0]['message_id'];Laravel
In config/services.php:
'splashify' => ['key' => env('SPLASHIFY_API_KEY')],use Illuminate\Support\Facades\Http;
Http::withToken(config('services.splashify.key'))
->post('https://apis.splashifypro.com/api/v1/partner/email/send', [
'from' => 'hello@yourcompany.com',
'to' => ['customer@example.com'],
'subject' => 'Welcome',
'html_body' => '<h1>Welcome</h1>',
])
->throw();