1. Go to this page and download the library: Download socketlabs/email-delivery 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/ */
socketlabs / email-delivery example snippets
//or if using composer: bsClient;
use Socketlabs\Message\BasicMessage;
use Socketlabs\Message\EmailAddress;
$client = new SocketLabsClient(000001, "YOUR-API-KEY"); //Your SocketLabs ServerId and Injection API key
$message = new BasicMessage();
$message->subject = "Sending A Basic Message";
$message->htmlBody = "<html>This is the Html Body of my message.</html>";
$message->plainTextBody = "This is the Plain Text Body of my message.";
$message->from = new EmailAddress("[email protected]");
$message->replyTo = new EmailAddress("[email protected]");
//A basic message supports up to 50 recipients and supports several different ways to add recipients
$message->addToAddress("[email protected]"); //Add a To address by passing the email address
$message->addCcAddress("[email protected]", "Recipient #2"); //Add a CC address by passing the email address and a friendly name
$message->addBccAddress(new EmailAddress("[email protected]")); //Add a BCC address by passing an EmailAddress object
$response = $client->send($message);
//or if using composer: BulkMessage;
use Socketlabs\Message\BulkRecipient;
use Socketlabs\Message\EmailAddress;
use Socketlabs\SocketLabsClient;
$client = new SocketLabsClient(000001, "YOUR-API-KEY"); //Your SocketLabs ServerId and Injection API key
//Build the message
$message = new BulkMessage();
$message->subject = "Sending A Bulk Message";
$message->htmlBody = "<html>This is the Html Body of my message sent to the recipient with %%EyeColor%% eyes.</html>";
$message->plainTextBody = "This is the Plain Text Body of my message sent to the recipient with %%EyeColor%% eyes.";
$message->from = new EmailAddress("[email protected]");
$message->replyTo = new EmailAddress("[email protected]");
//Add Bulk Recipients
$recipient1 = $message->addToAddress("[email protected]", "Recipient #1");
$recipient1->addMergeData("EyeColor", "Green");
$recipient2 = $message->addToAddress("[email protected]", "Recipient #2");
$recipient2->addMergeData("EyeColor", "Blue");
//Create the client and send the message
$response = $client->send($message);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.