Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
mailofly/mailofly
composer require mailofly/mailofly
<?php use Mailofly\Client; use Mailofly\MailoflyException; $client = new Client( getenv('MAILOFLY_API_KEY'), );
try { $result = $client->emails->send([ 'from' => 'Acme <onboarding@example.com>', 'to' => ['alex@example.com'], 'subject' => 'Hello', 'html' => '<p>Thanks for signing up.</p>', ]); echo $result['id']; } catch (MailoflyException $e) { fwrite(STDERR, "{$e->status} {$e->error} {$e->detailMessage}\n"); throw $e; }
$client->emails->send([ 'from' => 'Acme <onboarding@example.com>', 'to' => ['alex@example.com'], 'template' => [ 'id' => 'uuid-of-template', 'variables' => ['first_name' => 'Alex'], ], ]);
$client->compose->send
/v1/emails
$result = $client->batch->send([ [ 'from' => 'Acme <onboarding@example.com>', 'to' => ['foo@example.com'], 'subject' => 'hello world', 'html' => '<h1>it works!</h1>', ], [ 'from' => 'Acme <onboarding@example.com>', 'to' => ['bar@example.com'], 'subject' => 'world hello', 'html' => '<p>it works!</p>', ], ]);
$client->identities
list
get
update
delete
$client->accounts
$client->contacts
create
$client->templates
$client->segments
contacts->list/add/remove
$client->campaigns
runs
send
$client->emails
$client->batch
$client->compose
$client->mailLogs
$identities = $client->identities->list(); $client->contacts->create([ 'email' => 'alex@example.com', 'first_name' => 'Alex', 'custom_fields' => ['plan' => 'pro'], ]); $client->campaigns->send('campaign-uuid', ['send_now' => true]); $logs = $client->mailLogs->list(['page' => 1, 'page_size' => 50, 'status' => 'failed']);
$meta = Client::discovery(); print_r($meta['resources']);
use Mailofly\MailoflyException; try { $client->identities->list(); } catch (MailoflyException $e) { // $e->status, $e->error, $e->detailMessage }