The SocketLabs Email Delivery PHP library allows you to easily send any type of email message supported by our Injection API, from a simple message to a single recipient, to a complex bulk message sent to multiple recipients.

Send Bulk Email Without Having to Build & Maintain Your Own SMTP Email Servers

Basic Message

A basic message is an email message like you’d send from a personal email client such as Outlook. A basic message can have many recipients, including multiple, To Addresses, CC Addresses, and even BCC Addresses. You can also send a file attachment in a basic message.

$client = new SocketLabsClient(exampleConfig::000001, "YOUR-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);

 

Bulk Message

A bulk message usually contains a single recipient per message and is generally used to send the same content to many recipients, optionally customizing the message via the use of MergeData.

$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);

 

How to Get Started

To run these samples you will need to obtain an API Key and ServerId number from your SocketLabs Control Panel.

I Don’t Have a SocketLabs Account

Create Your Account

I Have a SocketLabs Account

Get Your API Key and Server ID

About Our Code Libraries

SocketLabs’ email API plays well with your favorite platforms and development frameworks, including .NET, PHP, Java, Node.js, Python, Go, and more! As a developer, our APIs for sending email give you all the tools you need to embed powerful email functionality into your applications.

SocketLabs  Developers

SocketLabs is built for developers, by developers.

Reach the inbox with industry-leading deliverability.

Integrate with your application in minutes.

Looking for More Libraries & Code Samples?

Speed up development with pre-built libraries and code samples for popular languages. Choose a library below!