PHP
Official MailSetu PHP SDK. Works with PHP 8.0+.
Installation
bash
composer require mailsetu/mailsetuSetup
php
<?php
require_once 'vendor/autoload.php';
$client = new MailSetu\MailSetu(getenv('MAILSETU_API_KEY'));Send an email
php
$response = $client->emails()->send([
'from' => 'Acme <noreply@acme.co>',
'to' => ['user@example.com'],
'subject' => 'Welcome to Acme!',
'html' => '<h1>Welcome!</h1>',
]);
echo $response['id']; // email-xxxxxxxxxxxxxxxx
echo $response['status']; // queuedStart an OTP verification
The same PHP client also covers SmsSetu and Verify / OTP workflows.
php
$service = $client->verify()->createService([
'name' => 'Login OTP',
'codeLength' => 6,
'ttlSeconds' => 300,
]);
$verification = $client->verify()->start([
'serviceId' => $service['id'],
'to' => '+919876543210',
'idempotencyKey' => 'login-otp-1',
]);
$result = $client->verify()->check($verification['id'], '123456');