Laravel
duta/duta-php includes a Laravel mail driver. Your existing Mailables,
notifications and Mail:: calls send through Duta without a code change.
It supports the Laravel releases that still receive security fixes, 12 and 13.
-
Install the package. Laravel finds it on its own.
Terminal window composer require duta/duta-php -
Set your key and choose the mailer in
.env:DUTA_API_KEY=duta_xxxxxxxxxxxxxxxxMAIL_MAILER=dutaMAIL_FROM_ADDRESS=resit@kedai.myMAIL_FROM_NAME="Kedai Runcit"The from address must be on a verified domain, or your sandbox address on the Free plan.
-
Send as you already do.
Mail::to($order->customer)->send(new OrderReceipt($order));
Everything a Mailable sets is carried over: from, to, cc, bcc, reply-to, the subject, the HTML and text bodies, attachments and custom headers. Names are kept exactly as written, even with quotes or commas in them.
Tags and idempotency
Section titled “Tags and idempotency”Two headers on a Mailable are read by the driver rather than sent:
use Illuminate\Mail\Mailables\Headers;
public function headers(): Headers{ return new Headers(text: [ 'X-Duta-Tag-type' => 'receipt', 'X-Duta-Idempotency-Key' => "receipt-{$this->order->id}", ]);}X-Duta-Tag-<name>becomes a tag: heretype=receipt.X-Duta-Idempotency-Keymakes the send safe to repeat for 24 hours. Use it on queued mail: if the job runs twice, the customer gets one email. See Idempotency.
Using the API directly
Section titled “Using the API directly”Inject Duta\Duta for everything beyond mail, such as usage or suppressions:
public function __construct(private \Duta\Duta $duta) {}
public function usage(): array{ return $this->duta->usage->get();}Configuration
Section titled “Configuration”The key comes from services.duta.key when set, otherwise DUTA_API_KEY.
To keep it in config/services.php:
'duta' => [ 'key' => env('DUTA_API_KEY'),],