PHP

Send email from PHP

composer require mailset-app/php, then $mailset->send() with an array. No other Composer package comes with it, and PHPStan checks every shape it takes and returns.

Open Mailset
Continue with Google

By starting you agree to the Terms and Privacy Policy.

Install

Install the PHP SDK

Composer, for PHP 8.1 or later with the curl, json and openssl extensions.

Composer
composer require mailset-app/php
Send

Send your first email from PHP

new Mailset\Client() reads MAILSET_KEY from the environment. The message is an array with the API’s own names, deliverBy included, and the answer is a readonly Sent: $sent->id, $sent->status. When Mailset refuses the message, send throws a MailsetException.

send.php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();

$sent = $mailset->send([
    'from' => 'Acme <moc.elpmaxe@olleh>',
    'to' => 'gro.elpmaxe@ana',
    'subject' => 'Your Acme code',
    'text' => 'Your code is 123456.',
    'html' => '<p>Your code is <b>123456</b>.</p>',
    'deliverBy' => '10m',
]);

echo $sent->id, ' ', $sent->status, PHP_EOL;
Webhooks

Delivery events in Laravel and Symfony

What happened to each message arrives at your app, one signed batch at a time. The Laravel and Symfony guides each have the route, which verifies $request->getContent() rather than the parsed input.

Domain

Send from your own domain

Your product sends as your own domain either way. What changes is where your team’s mail lives.

  • Sending only. Your team’s mail stays at Google, Microsoft or wherever it is now. Mailset asks for DKIM, a bounce host and DMARC, and leaves your MX alone. Send from a domain whose mail stays elsewhere
  • Mailboxes too. Your team’s mail moves to Mailset, with a real mailbox for every address on the domain and your product’s email on the same bill. Set up a domain
mailset domains add example.com --sendingmailset domains apply example.com --sendingmailset domains check example.commailset keys create --send --domain example.com --from moc.elpmaxe@olleh --name "Acme API"
Facts

What the PHP SDK’s build checks

Each line comes from the SDK’s own build, which fails when one stops being true.

FactDetailKnown from
PHP 8.1+The oldest its manifest allowsIts manifest
No dependenciesNothing else to install beside itIts manifest
Typed throughoutReadonly classes, checked by PHPStanA test
Next

Where to go from here

Pricing

Product email on every plan

  • Base$29a month10 members included
  • Team$79a month25 members included
  • BaseRegular price $29$14.50a month10 members included
  • TeamRegular price $79$39.50a month25 members included

Black Friday prices, for trials started by Thursday, Dec 31. Offer terms

Both include 10,000 emails a month, your product’s and your team’s together. Past that it’s $0.40 per 1,000 with pay as you go.

Every price, and what teams pay elsewhere

Questions

Sending from PHP, asked and answered

Do I still need mail() or PHPMailer?

No. The SDK sends over HTTPS with curl, so there’s no sendmail binary to configure and no SMTP account to sign in to.

Can I use it without a framework?

Webhooks::verify takes file_get_contents('php://input') and getallheaders() as they are, and send is plain PHP that any script can call.

How do I keep a retry from sending twice?

Give the message an idempotencyKey, such as receipt-8842. Sent again after a timeout or a crash, Mailset answers the first receipt and sends nothing new.

Make a key and sendTry it on your own domain

Make a key in Settings › Developers, keep it as MAILSET_KEY, and run the example above.7 days free, with everything on. Make a key, run the example above and watch the receipt come back.

Open Mailset
Continue with Google

By starting you agree to the Terms and Privacy Policy.