Skip to main content
Use the official PHP SDK to call the MailGlyph API from server-side apps.

Prerequisites

Before you start, make sure you have:
  • A MailGlyph secret API key (sk_...) for server-side API requests
  • A MailGlyph public API key (pk_...) for event tracking (/v1/track)
  • At least one verified sending domain for email sending
Setup links:

Install

Initialize clients

Create one SDK client for your secret key and one for your public key:
Set environment variables:

Configure base URL, timeout, and retries

Use this when testing against staging or local environments:

Key usage rules

The PHP SDK enforces key restrictions automatically:
  • pk_* keys can only call events->track()
  • sk_* keys can call non-track endpoints, including events->listNames() and events->getNames()
Unlike the Node.js SDK, the PHP SDK does not expose a keyType property on the client.

Next pages