Markdown

Groundmail with PHP

Use the PHP SDK in Laravel, Symfony, WordPress plugins, or any server-side PHP app where your API key can stay private.

Updated Nov 24, 20261 min read

Install the SDK

Terminal
composer require groundmail/groundmail

Configure your API key

Terminal
export GROUNDMAIL_API_KEY=gm_your_key_here

Send an email

PHP
<?php

use Groundmail\Client;

$tx = new Client(getenv('GROUNDMAIL_API_KEY'));

$result = $tx->emails->send([
    'from' => 'ops@yourdomain.com',
    'to' => 'user@example.com',
    'subject' => 'Your receipt',
    'html' => '<p>Thanks for your purchase.</p>',
]);

echo $result['id'], ' ', $result['status'], PHP_EOL;

Resources

The client includes thin wrappers for common API resources:

  • $tx->emails — send, batch, list, cancel, resend, test webhooks, deliverability insights
  • $tx->domains — create, verify, apply DNS, update, delete
  • $tx->webhooks — CRUD for webhook endpoints
  • $tx->templates — CRUD plus publish
  • $tx->suppressions — list, create, remove
  • $tx->validate($email) and $tx->validateBatch($emails) — check addresses before you accept them (validation); mailboxCheck: true also confirms the mailbox exists

See the API reference for request fields. The PHP SDK accepts the same JSON shapes as the REST API.

For Symfony Mailer, use groundmail/symfony-mailer. For Laravel, use groundmail/laravel (config, container binding, Facade — built on the Symfony transport).

Source

Package source lives in Groundmail/groundmail-php (Packagist requires composer.json at repo root).

Was this page helpful?