PHP
Changelog
Every release of the package, newest first.
0.0.1
The first release of the PHP package. It has a method for every one of the 684 methods of the TypeScript SDK, in 53 namespaces, each under its TypeScript name, and a parity check in the package’s own build proves that every one sends the same request as its TypeScript twin, retries the same way and returns the same shape.
Nextmail\Nextmailhas a property for every namespace, fromemails,threadsandtemplatestoautomations,bookingsandconnectedMailboxes. A request body is an associative array whose keys keep the API’s camelCase names, the options of a call are named arguments such asidempotencyKey:andlimit:, and a response comes back as the decoded associative array.new Nextmail()andNextmail::createClient()takeapiKey:oraccessToken:, andaccessToken:also takes a callable that returns a token, called before every request. Anything you leave out is read fromNEXTMAIL_API_KEY,NEXTMAIL_ACCESS_TOKENandNEXTMAIL_BASE_URL, andbaseUrl:,timeout:,maxRetries:,headers:,userAgent:andhttpClient:set the rest. Every method takesapiKey:, orinboxToken:ontempMail, to act with another credential for one call.Nextmail::init(),Nextmail::getClient()andNextmail::resetClient()manage one shared client, andNextmail::createTempMail()opens disposable inboxes with no credential.- Every paginated resource has
list, which returns oneNextmail\Result\Pagewithitems,hasMoreandnextCursor,listAll, which returns every item as an array, anditerate, which returns a Generator that fetches the next page only when it gets there. - An API refusal throws
Nextmail\Exception\ApiExceptionor its subclass for the error type, such asNotFoundException,ValidationExceptionorRateLimitException, withstatus,type,errorCode,param,docUrl,requestId,retryAfterSecondsandfields, and methods such asisValidation(),isStepUpRequired()andisRetryable(). No response at all throwsNetworkException, withisTimeout()when the deadline passed, and a mistake in the call itself throwsInvalidArgumentExceptionbefore anything is sent. Every exception the package throws implementsNextmail\Exception\NextmailException. - Reads, sends and every write that is safe to repeat are retried on 408, 500, 502, 503 and 504 with backoff, and on a 429 only when its
Retry-Afteris a minute or less. A send carries an idempotency key that its retries reuse, so a retry never sends a second message.timeout:bounds a whole attempt, and uploads wait at least ten minutes. Nextmail::verifyWebhookSignature()checks a delivery in constant time, refuses one more than five minutes old and returns the decoded event. It reads the signature from an array of headers in any case, from$_SERVER, from a Symfony or Laravel header bag, or from a PSR-7 message.- The helpers of the TypeScript SDK are here too, such as
Nextmail::toBase64()andNextmail::resolveLanguage(), and every value set it exports is a class inNextmail\Constants, such asWebhookEventsandApiScopes, with avalues()method for the whole set. - Requests go through one cURL handle per client, which keeps its connection open between requests and opens a new one after
pcntl_fork.Nextmail\Http\Psr18HttpClientsends them through Guzzle, Symfony HttpClient or any other PSR-18 client instead, and anything that implementsNextmail\Http\HttpClientcan take the place of either, which is how a test runs without a network. - Credentials stay out of sight: every parameter that carries one is marked
#[\SensitiveParameter], no dump of a client or a request shows one, and the client never sends one over plainhttp:to anything but this machine. - When a newer version is on Packagist, the client says so once, on the command line and only on a terminal.
disableUpdateNotice: trueorNEXTMAIL_DISABLE_UPDATE_NOTICE=1turns that off. - It needs PHP 8.2 or later with the curl and json extensions, and nothing else.
Google Workspace