Skip to content
Splashify Pro
Email docsEmail

PHP Quickstart

php
<?php
$ch = curl_init('https://api.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'      => '[email protected]',
    'to'        => ['[email protected]'],
    '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:

php
'splashify' => ['key' => env('SPLASHIFY_API_KEY')],
php
use Illuminate\Support\Facades\Http;

Http::withToken(config('services.splashify.key'))
    ->post('https://api.splashifypro.com/api/v1/partner/email/send', [
        'from' => '[email protected]',
        'to' => ['[email protected]'],
        'subject' => 'Welcome',
        'html_body' => '<h1>Welcome</h1>',
    ])
    ->throw();

What's next