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_secret_api_key_here" );
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 ();
}
The SendSculpt API automatically handles environments based on your API key. Use a Sandbox key for testing and a Live key for
production.
Framework Integrations
Use the provided Service Provider by placing SendSculptServiceProvider.php in your app/Providers directory. In config/app.php, add the provider to the providers array: 'providers' => [
// ...
App\Providers\ SendSculptServiceProvider :: class ,
],
In config/services.php, append the following: 'sendsculpt' => [
'key' => env ( 'SENDSCULPT_API_KEY' )
],
Update your .env file: SENDSCULPT_API_KEY="your-api-key"
Usage in Controller 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 config/services.yaml: parameters :
sendsculpt_api_key : '%env(SENDSCULPT_API_KEY)%'
services :
SendSculpt\SendSculptClient :
arguments :
$apiKey : '%sendsculpt_api_key%'
Usage in Controller 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 );
}
}
}