1. Go to this page and download the library: Download emailit/emailit-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/ */
// Create a domain
$domain = $emailit->domains()->create([
'name' => 'example.com',
'track_loads' => true,
'track_clicks' => true,
]);
echo $domain->id;
// Verify DNS
$domain = $emailit->domains()->verify('sd_123');
// List all domains
$domains = $emailit->domains()->list();
// Get a domain
$domain = $emailit->domains()->get('sd_123');
// Update a domain
$domain = $emailit->domains()->update('sd_123', ['track_clicks' => false]);
// Delete a domain
$emailit->domains()->delete('sd_123');
// Create an API key
$key = $emailit->apiKeys()->create([
'name' => 'Production Key',
'scope' => 'full',
]);
echo $key->key; // only available on create
// List all API keys
$keys = $emailit->apiKeys()->list();
// Get an API key
$key = $emailit->apiKeys()->get('ak_123');
// Update an API key
$emailit->apiKeys()->update('ak_123', ['name' => 'Renamed Key']);
// Delete an API key
$emailit->apiKeys()->delete('ak_123');
// Create an audience
$audience = $emailit->audiences()->create(['name' => 'Newsletter']);
echo $audience->id;
echo $audience->token;
// List audiences
$audiences = $emailit->audiences()->list();
// Get an audience
$audience = $emailit->audiences()->get('aud_123');
// Update an audience
$emailit->audiences()->update('aud_123', ['name' => 'Updated Newsletter']);
// Delete an audience
$emailit->audiences()->delete('aud_123');
// Add a subscriber
$subscriber = $emailit->subscribers()->create('aud_123', [
'email' => '[email protected]',
'first_name' => 'John',
'last_name' => 'Doe',
]);
// List subscribers in an audience
$subscribers = $emailit->subscribers()->list('aud_123');
// Get a subscriber
$subscriber = $emailit->subscribers()->get('aud_123', 'sub_456');
// Update a subscriber
$emailit->subscribers()->update('aud_123', 'sub_456', [
'first_name' => 'Jane',
]);
// Delete a subscriber
$emailit->subscribers()->delete('aud_123', 'sub_456');
// Create a template
$result = $emailit->templates()->create([
'name' => 'Welcome',
'subject' => 'Welcome!',
'html' => '<h1>Hi {{name}}</h1>',
]);
// List templates
$templates = $emailit->templates()->list();
// Get a template
$template = $emailit->templates()->get('tem_123');
// Update a template
$emailit->templates()->update('tem_123', ['subject' => 'New Subject']);
// Publish a template
$emailit->templates()->publish('tem_123');
// Delete a template
$emailit->templates()->delete('tem_123');
// Create a suppression
$suppression = $emailit->suppressions()->create([
'email' => '[email protected]',
'type' => 'hard_bounce',
'reason' => 'Manual suppression',
]);
// List suppressions
$suppressions = $emailit->suppressions()->list();
// Get a suppression
$suppression = $emailit->suppressions()->get('sup_123');
// Update a suppression
$emailit->suppressions()->update('sup_123', ['reason' => 'Updated']);
// Delete a suppression
$emailit->suppressions()->delete('sup_123');