PHP code example of sendkit / sendkit-laravel

1. Go to this page and download the library: Download sendkit/sendkit-laravel 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/ */

    

sendkit / sendkit-laravel example snippets


Mail::to('[email protected]')->send(new WelcomeEmail());

use SendKit\Laravel\Facades\SendKit;

$response = SendKit::emails()->send([
    'from' => '[email protected]',
    'to' => '[email protected]',
    'subject' => 'Hello',
    'html' => '<h1>Welcome!</h1>',
]);

use SendKit\Laravel\Facades\SendKit;

// Create or update a contact (upsert by email)
$contact = SendKit::contacts()->create([
    'email' => '[email protected]',
    'first_name' => 'John',
    'last_name' => 'Doe',
    'list_ids' => ['list-uuid-1'],
    'properties' => ['COMPANY' => 'Acme'],
]);

// List contacts (paginated)
$contacts = SendKit::contacts()->list();
$contacts = SendKit::contacts()->list(['page' => 2]);

// Get a single contact
$contact = SendKit::contacts()->get('contact-uuid');

// Update a contact
$contact = SendKit::contacts()->update('contact-uuid', [
    'first_name' => 'Johnny',
]);

// Delete a contact
SendKit::contacts()->delete('contact-uuid');

// Add a contact to lists
SendKit::contacts()->addToLists('contact-uuid', ['list-uuid-1', 'list-uuid-2']);

// List a contact's lists
$lists = SendKit::contacts()->listLists('contact-uuid');

// Remove a contact from a list
SendKit::contacts()->removeFromList('contact-uuid', 'list-uuid');

use SendKit\Laravel\Facades\SendKit;

// Create a property ("string", "number", or "date")
$property = SendKit::contactProperties()->create([
    'key' => 'company',
    'type' => 'string',
    'fallback_value' => 'N/A',
]);

// List all properties
$properties = SendKit::contactProperties()->list();

// Update a property
SendKit::contactProperties()->update('property-uuid', [
    'key' => 'organization',
]);

// Delete a property
SendKit::contactProperties()->delete('property-uuid');

use SendKit\Laravel\Facades\SendKit;

$result = SendKit::validateEmail('[email protected]');

$result['is_valid'];       // "HIGH" or "LOW"
$result['should_block'];   // true if the email should be blocked
$result['block_reason'];   // reason for blocking, or null
$result['evaluations'];    // detailed evaluation results

use SendKit\Laravel\Events\EmailDelivered;

Event::listen(EmailDelivered::class, function ($event) {
    // $event->payload contains the webhook data
});
bash
php artisan vendor:publish --tag=sendkit-config