1. Go to this page and download the library: Download sendclipper/sendclipper-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sendclipper / sendclipper-php example snippets
use SendClipper\SendClipper;
$sc = new SendClipper('sc_live_xxxxxxxxxxxxxxxx');
// or: new SendClipper() reads SENDCLIPPER_API_KEY
[$data, $error] = $sc->emails->send([
'from' => '[email protected]',
'to' => '[email protected]',
'subject' => 'Your receipt',
'html' => '<p>Thanks for your order.</p>',
'text' => 'Thanks for your order.',
]);
if ($error) {
echo $error->name, ': ', $error->message; // e.g. domain_not_verified
} else {
echo "Email {$data['id']} accepted";
}
use SendClipper\Exception\WebhookVerificationException;
use SendClipper\Webhook;
try {
$event = Webhook::verify(
file_get_contents('php://input'), // the raw body, not json_decode()d
getallheaders(),
(string) getenv('SENDCLIPPER_WEBHOOK_SECRET'),
);
} catch (WebhookVerificationException $e) {
http_response_code(400);
exit($e->reason);
}
// $event['id'] is stable across retries: deduplicate on it
error_log($event['event'] . ' ' . $event['data']['to']);
http_response_code(200);
$box = $sc->sandboxes->create(['name' => 'my-app-dev'])->unwrap();
$creds = $sc->sandboxes->credentials($box['id'])->unwrap(); // SMTP host, port, username, password
// Or send through the sandbox's JSON door with its own token, using the same fields as emails->send():
$token = $sc->sandboxes->resetCredentials($box['id'])->unwrap();
$sc->sandboxes->send($token['apiToken'], ['from' => '[email protected]', 'to' => '[email protected]', 'subject' => 'Hi', 'html' => '<p>Hi</p>']);
// In a test: wait for the message to arrive
[$msg, $error] = $sc->sandboxes->messages->waitFor($box['id'], fn (array $m) => $m['subject'] === 'Hi');
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.