Skip to main content
The official PHP implementation for sending emails via the SendSculpt Mailer API. Works natively or within Laravel, CodeIgniter, and Symfony.
Requires PHP 7.4+, ext-curl, and ext-json

Installation

Install using Composer:
composer require sendsculpt/sdk

Vanilla PHP

Initialize the client, passing the API Key.
require_once 'path/to/SendSculptClient.php';

use SendSculpt\SendSculptClient;

$client = new SendSculptClient('your-api-key', 'https://api.sendsculpt.com/api/v1');

try {
    $response = $client->sendEmail([
        'to' => ['recipient@example.com'],
        'subject' => 'Welcome to SendSculpt!',
        'from_email' => 'noreply@yourdomain.com',
        'body_html' => '<b>Hello!</b> This is a test from PHP.',
        'attachments' => [
            [
                'filename' => 'document.txt',
                'file_path' => '/path/to/local/document.txt', // Auto-converts to Base64
                'mime_type' => 'text/plain'
            ]
        ]
    ]);

    echo "Email sent successfully! Message ID: " . $response['message_id'];
} catch (Exception $e) {
    echo "Error sending email: " . $e->getMessage();
}

Framework Integrations

Use the provided Service Provider. Update .env with SENDSCULPT_API_KEY="your-api-key".
namespace App\Http\Controllers;

use SendSculpt\SendSculptClient;

class EmailController extends Controller
{
    public function send(SendSculptClient $client)
    {
        $response = $client->sendEmail([
            'to' => ['john@doe.com'],
            'subject' => 'Laravel SendSculpt Test',
            'from_email' => 'test@yourdomain.com',
            'body_text' => 'It works perfectly in Laravel!'
        ]);

        return response()->json($response);
    }
}
Inject it within your BaseController or explicitly initialize it.
namespace App\Controllers;

use SendSculpt\SendSculptClient;

class MailController extends BaseController
{
    public function index()
    {
        $apiKey = getenv('SENDSCULPT_API_KEY');
        $client = new SendSculptClient($apiKey);

        try {
            $response = $client->sendEmail([
                'to' => ['recipient@example.com'],
                'from_email' => 'noreply@yourdomain.com',
                'subject' => 'CodeIgniter Integration',
                'template_id' => 'your-template-id',
                'template_data' => ['name' => 'John Doe']
            ]);

            return $this->response->setJSON(['status' => 'success', 'data' => $response]);
        } catch (\Exception $e) {
            return $this->response->setStatusCode(500)->setJSON(['error' => $e->getMessage()]);
        }
    }
}
Register SendSculptClient as a service in services.yaml.
namespace App\Controller;

use SendSculpt\SendSculptClient;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;

class MailerController
{
    #[Route('/test-email', name: 'test_email')]
    public function index(SendSculptClient $client): JsonResponse
    {
        try {
            $response = $client->sendEmail([
                'to' => ['user@example.com'],
                'subject' => 'Symfony Integration',
                'from_email' => 'hello@yourdomain.com',
                'body_html' => '<h1>Hello from Symfony</h1>'
            ]);

            return new JsonResponse($response);
        } catch (\Exception $e) {
            return new JsonResponse(['error' => $e->getMessage()], 500);
        }
    }
}