Skip to content

PHP SDK

The official PHP client. Uses cURL, no third-party dependencies.

Terminal window
composer require duta/duta-php
require 'vendor/autoload.php';
$duta = new \Duta\Client('duta_live_xxx');
$result = $duta->emails->send([
'from' => 'hello@yourdomain.com',
'to' => 'user@example.com',
'subject' => 'Welcome',
'html' => '<p>Thanks for signing up!</p>',
]);
echo "Sent: " . $result['id'];

Methods throw \Duta\DutaException on failure:

use Duta\DutaException;
try {
$duta->emails->send([ /* ... */ ]);
} catch (DutaException $e) {
echo $e->statusCode . ' ' . $e->name . ': ' . $e->getMessage();
// $e->name: authentication_error | permission_denied | rate_limit_exceeded | ...
}
  • $duta->emails->send($params): send an email. Keys: from, to (string or array), subject, html, text, reply_to, tags.
  • $duta->emails->get($id): retrieve an email. Requires a full-access key.
  • $duta->emails->list($page = 1, $limit = 20): list emails. Requires a full-access key.

Package: packagist.org/packages/duta/duta-php · Source: github.com/indra-sh/duta-php.