Download the PHP package recado/recado-php without Composer

On this page you can find all versions of the php package recado/recado-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package recado-php

Recado PHP SDK

Official PHP SDK for the Recado REST API v1. It wraps the transactional send, contacts, lists, segments, tags, templates, messages, campaigns, broadcasts, waitlists, webhook endpoints, events, sending and custom domains and email verification behind typed resources and readonly DTOs, with first-class error handling and idempotency support — plus an optional, batteries-included Laravel integration.

⚠️ Read-only mirror. This repo is an automated split of the SDK from a private monorepo. Do not open pull requests here — they can't be merged (the mirror is force-pushed) and will be auto-closed. Found a bug or have a request? Open an issue (see CONTRIBUTING).

🤖 Integrating with an AI agent? Start with AGENTS.md — a terse, imperative integration playbook with the human-gate steps called out. This README is the full human reference.

Features

Requirements

Installation

The package is published on Packagist — require it directly with Composer, no repository entry or Git/SSH access needed:

Migrating from mosaiqo/mailer-php (v1.x)? v2.0.0 is the same SDK under the new brand — no functional changes, but every brand-carrying name was renamed: package mosaiqo/mailer-php → recado/recado-php, namespace Mailer\Sdk → Recado\Sdk, classes Mailer* → Recado* (client, facade, service provider, transport, channel, message, headers, exceptions), toMailer() → toRecado(), env vars MAILER_* → RECADO_*, config mailer-sdk → recado-sdk, transport/channel string mailer → recado, and message headers X-Mailer-* → X-Recado-*. See the CHANGELOG for the full matrix.

Path repository (monorepo development)

When developing inside the Recado monorepo, point Composer at the package directory with a path repository:

Quick start: integrate into a Laravel app

The full, copy-pasteable recipe to route a real Laravel app's email through a Recado instance. (Detailed behavior and options are documented further down.)

1. Require the package (published on Packagist):

2. Set the environment variables.

Where to get the API key. In Recado, open Settings → API keys for the project you want to send from and create a key (it is shown once — copy it straight into RECADO_API_TOKEN). Keys are per project, so the key also selects which project's sender, templates and contacts the sends use.

3. Add the recado mailer to config/mail.php.

4. Send. Nothing else in your mailing code changes:

Or call the API client directly — e.g. to render a stored template by slug with per-recipient variables:

That is the whole integration. The rest of this document covers the SDK's full surface and the transport's detailed behavior.

Plain PHP usage

Batch sends

No attachments in batches. /send/batch rejects messages.*.attachments with a 422 — attachments are single-send only. Call send()->email() per recipient instead (the Laravel mail transport does this fan-out for you).

Notifications (in-app & push)

Send a notification to a contact over one or more channels. Without a channels key the SDK sends in_app; pass channels to fan out (e.g. in-app and push):

Per-channel failures are data, not exceptions. Each requested channel comes back as a NotificationChannelResult, so one channel failing never aborts the others — and when no channel can be queued (the API replies 422 with the same envelope) you still get a NotificationResult (anyQueued() is false) rather than a thrown exception. A real validation error (missing title, etc.) still throws ValidationException.

status errorCode Meaning
queued — Accepted for delivery on that channel.
failed_precondition push_provider_not_configured Push not set up for the project.
blocked recipient_blocked Recipient is suppressed/blocked.
blocked quota_exceeded Monthly email/notification quota is out.
blocked sandbox_cap_exceeded Sandbox project send cap reached.

Push prerequisites: the project must have a push provider configured and the contact must have at least one registered device token (see below).

Notification templates

Instead of inline title/body, pass a template slug (a notification template managed in the dashboard under Transactional → Notification templates) plus optional variables — the two content modes are mutually exclusive:

The API resolves the template's locale variants per recipient (contact locale — exact tag, then language prefix — then the project default locale, then the base content) and snapshots the resolved content on the queued message, so deleting the template never breaks in-flight sends. The template's action_url/icon act as defaults that a per-send value overrides. An unknown slug throws a ValidationException with code template_not_found (like send()->email()). Batch items accept the same template field; there an unknown slug is a per-item, per-channel outcome (status failed_precondition, errorCode template_not_found) that never aborts the batch.

Batch notifications

Send up to 100 notifications in one request (rate limited to 10 requests/min per token). Each item takes the same fields as send(), and an item without channels defaults to ['in_app']:

queued and failed count channel dispatches, not items: a two-channel item whose push failed contributes to both. Unlike send(), the batch endpoint always answers 202 — even when nothing at all could be queued — because a batch has no single meaningful outcome; the per-channel error codes are the same ones listed above (plus upgrade_required when the plan does not include push). A single malformed item rejects the whole request with a ValidationException keyed by index (e.g. messages.2.title).

Idempotency keys work at the batch level (1–255 chars, 24h replay) and live in their own namespace, so a /send/batch key with the same string is unrelated. A retry arriving while the first request is still in flight throws a RecadoException with status 409 and code idempotency_conflict; a batch that queued nothing does not consume its key.

Push device tokens

Register and remove the device tokens push notifications are delivered to. The contact is upserted with transactional semantics (no double opt-in):

The platform is the native device platform: ios or android. This endpoint registers native FCM device tokens only — web push uses a separate VAPID subscription flow, so web is not accepted here (passing it yields a 422).

Registering a token already owned by another contact in the project moves it to this contact; a contact is capped at 20 devices (the oldest is evicted past the cap). Removing a token from an unknown contact raises a NotFoundException (contact_not_found).

Idempotency

email() and batch() accept a named idempotencyKey argument, sent as the Idempotency-Key header. Re-sending with the same key returns the original result instead of creating a duplicate. While the first request is still in flight a concurrent retry with the same key gets a 409 — surfaced as a base RecadoException with code idempotency_conflict; an empty or over-long key is rejected with a 422 ValidationException (code invalid_idempotency_key).

Other resources

Paginated endpoints return a Paginated DTO exposing ->data (mapped DTOs), ->meta and ->links. The tags and webhooks listings return flat arrays.

Campaigns

The campaigns resource covers the whole newsletter lifecycle: create and edit a draft, inspect it before sending, then send, schedule, cancel, duplicate or delete it.

A/B testing

Pass ab_test and variants to the same create() / update() calls — the whole test is authored in one request, no dashboard round trip:

Every variant field (subject, preheader, from_name, from_email, content) is optional and a null one inherits the campaign's own; the variant content always uses the campaign's editor shape, since a variant never has an editor of its own. variants replaces the whole set on each write, so editing or removing one means sending the set you want; ['enabled' => false] turns the test off and clears them.

The authored test comes back as $campaign->abTest on every read and write (no include needed). Once the test group has gone out it is frozen:

Two variants are required to SEND (not to save a half-built draft) — the ab_variants readiness check reports ab_invalid_variants, or missing_subject / missing_content with the offending label in its meta. Enabling the test needs the A/B plan feature; without it the write is a 422 with ab_test_requires_plan.

Languages (locale variants)

One campaign, one audience, each recipient in their own language. locale_variants rides the same create() / update() calls, and each A/B variant may carry its own — the full matrix:

locale is required and normalized, so es_mx and ES-mx are the same language and listing both is a 422. subject, preheader and content are each optional and a null one inherits the layer below — the A/B variant, then the campaign. A translation carries no sender (who a campaign sends from is not a language decision) and no editor of its own: content follows the campaign's editor, exactly like a variant's.

Each list replaces the whole set for its scope on every write, so [] removes every translation there, and a partial update that never mentions the key leaves the stored translations untouched. Per recipient the contact's locale is tried first, then the project's default_locale, each as the exact tag (es-MX) and then as its language prefix (es); nothing matches → the campaign base, byte-identical to an untranslated campaign.

Both preview() and testSend() take a locale, rendering exactly what a recipient in that language would receive:

The authored translations come back on every read and write (no include needed) as $campaign->localeVariants, with the per-variant ones on $campaign->abTest->variants[*]->localeVariants; the listing never carries them, so a list row has empty arrays. The advisory locale_variants readiness check never blocks a send — it names in its meta the languages whose resolved subject or body would be empty.

Sending requires an explicit confirmation. send() fires real mail at a real audience and cannot be recalled once the batch is queued, so the intent has to be spelled out at the call site:

Without confirm: true the exception is thrown before any HTTP request is made — a stray or accidental send() never reaches the API, let alone the audience. (This replaces the old posture, where the resource simply had no write methods at all.) Nothing else needs confirming: schedule() only arms a future send that unschedule() or cancel() can still stop.

Reporting:

Failures keep the API's machine codes on the typed exceptions, untranslated — $e->getErrorCode() returns not_sendable, missing_subject, missing_content, no_recipients, sending_domain_not_verified, quota_exceeded, ab_invalid_variants, campaign_not_editable, campaign_not_cancellable, campaign_not_deletable, premium_monetization_disabled.

Broadcasts

A broadcast is a mass in-app and/or push notification send — the notification sibling of a campaign. Email is deliberately not a broadcast channel: mass email is what campaigns are for. The lifecycle mirrors campaigns field for field, so code that drives one drives the other.

Failures keep their machine codes: not_sendable, missing_content, no_channels, no_recipients, push_not_entitled, push_not_configured, quota_exceeded, broadcast_not_editable, broadcast_not_scheduled, broadcast_not_cancellable, recipient_blocked.

Waitlists

A waitlist is a hosted pre-launch signup page (/w/{slug}) with referral positions. The SDK covers the read side plus the one irreversible action: authoring stays in the dashboard, because creating a waitlist also creates its dedicated contact list and claims a globally unique public slug.

Launching is irreversible — there is no unlaunch, here or in the dashboard:

A second launch (and the loser of a concurrent one) throws a ValidationException with the code waitlist_already_launched; an unknown or cross-project id is a NotFoundException with waitlist_not_found.

Permissions reuse the contacts pair: contacts.view to read, contacts.manage to launch.

Sending domains

The automated-onboarding loop: add the domain, read back the DNS records to publish, pipe them into your DNS provider, poll, clean up — without anyone opening the dashboard.

state is the field worth polling, because it blends the provider's truth with Recado's own live DNS lookups:

state Meaning
verified The provider confirms it. The only source of truth for sending.
detected Recado's resolver already sees the value, the provider is still pending. Never promoted to verified on that detection alone.
not_found Not published yet. The only "your turn" state — missingRecords() returns exactly these.
failed The provider reports failure.

Every representation performs live DNS lookups, so treat these calls as a status poll, not a hot path.

Refusals keep their machine codes: verification_unsupported (the active provider has no domain API — generic SMTP, or Postmark without the optional account token — so the row could never leave pending), already_added, provider_error and verification_failed (the provider could not be reached; the stored status is untouched and the call is worth retrying).

SendingDomain::$warmup mirrors the dashboard's ramp block for a warming identity. Skipping a ramp and resuming a breaker-paused identity have no API and the SDK fakes none: they are judgement calls about sending reputation and stay in the dashboard, where the trip rates sit in front of a human.

Not available in a sandbox — see Production-only endpoints below.

Custom domains

The project's own public hostname (news.customer.com). Once verified, public pages, webviews, tracking and unsubscribe links are served on it; until then (and if it later breaks) everything falls back to the platform subdomain, so links in already-sent mail keep working.

One domain per project. The collection is a collection for forward compatibility; today it holds 0 or 1 element, and current() collapses that:

Verification has two gates, both run by check(): the CNAME ownership proof (A-records deliberately do not verify — failure is cname_missing) and a TLS-live probe of https://{hostname}/up. verificationError and tlsError stay machine codes: an integration branches on them, and a localized sentence is not a contract.

Adding requires the custom_domains plan entitlement (422 custom_domains_not_entitled); checking and deleting stay ungated, so a downgraded team keeps managing the domain it already has. Other refusals: custom_domain_limit_reached, and check_throttled (one check per domain per 15 minutes, with retry_after seconds on the response body).

Not available in a sandbox — see Production-only endpoints below.

Email verification (billed)

Every contact already carries Recado's free verdict (Contact::$verificationStatus: valid, risky, invalid, unknown), computed in-process with no external provider. The API only marks, it never rejects — the one place the verdict changes behaviour is campaign audiences, where invalid contacts are excluded like suppressed ones.

On top of that, a project can connect its own ZeroBounce or Kickbox account and ask for mailbox-level verification. Those lookups are billed per address to that account and there is no refund, so the SDK keeps the cost gate first-class: run() takes the estimate object, never a bare number.

addresses is smaller than contactsInScope whenever addresses already carry an external verdict newer than the re-verify window (30 days by default): those are skipped and cost nothing, which is what makes re-running the same list cheap. Omit both arguments to scope the estimate to the whole audience; contactIds is capped at 5000.

If the audience moved between the estimate and the run, the platform refuses to spend on a figure nobody has seen — and hands you the current one:

It extends ValidationException, so code that only catches that keeps working. Other refusals: verification_not_configured (no provider, or one switched off — a disabled provider must never spend credits), 409 verification_already_running (one run per project at a time), list_not_found and verification_run_not_found. The gate applies in a sandbox too.

Production-only endpoints

Sending domains, custom domains and delivery health are refused for a sandbox credential: a sandbox never sends externally and never serves customer-facing pages, so it has no sending identities, no public hostname and no sending reputation — and its token must not reach the production project's.

Branch on the code, not the status. The platform is unifying those refusals on 404 (they used to be a mix of 404 and 422), so the SDK exposes the check on the exception base class:

$client->project()->get()->isSandbox() answers the same question up front, without provoking a refusal.

Automatic pagination

Paginated resources also expose a cursor() generator that lazily walks every page for you, fetching one page at a time and yielding each mapped DTO. You never track page numbers — just iterate:

A cursor() returns a plain \Generator (the core SDK never depends on Illuminate). In a Laravel app you can wrap it in a LazyCollection to use the collection pipeline:

Resilience (automatic retries)

When you let the SDK build its own HTTP client (the default — you do not inject a Guzzle client), it installs an automatic retry middleware with exponential backoff.

Tune it through the optional options argument (4th constructor parameter):

When you inject your own Guzzle client it is used as-is — add the retry middleware yourself via Recado\Sdk\Http\RetryMiddleware::make() if you want it.

Error handling

Every non-2xx response is mapped to a typed exception. All exceptions extend Recado\Sdk\Exception\RecadoException and expose:

Exception HTTP status Notes
AuthenticationException 401 Missing/invalid/expired token.
NotFoundException 404 e.g. contact_not_found, template_not_found, message_not_found; a sandbox simulate() from a production token gets a bare 404 (no code).
ValidationException 422 Validation failures and domain rejections (recipient_suppressed, quota_exceeded, template_not_found, invalid_status_transition, sandbox invalid_event_for_channel / link_index_out_of_range, ...). Adds errors(): array (field => messages).
VerificationEstimateMismatchException 422 Subclass of ValidationException for estimate_mismatch: a billed verification run was refused because the scope moved. Adds currentEstimate(): ?VerificationEstimate, ready to hand back to run().
RateLimitException 429 Adds retryAfter(): ?int parsed from the Retry-After header.
RecadoConfigurationException — (local) Missing/empty/placeholder base URL (or the decommissioned mailer.mosaiqo.com v1.x host) or empty token; thrown at client construction before any request.
UnsupportedFeatureException — (local) The send relies on something the /send API has no field for, or that the SDK config disables (e.g. attachments with recado-sdk.mail.attachments = 'fail').
AttachmentsTooLargeException — (local) The decoded attachments of one send exceed the 10 MB total limit; thrown before any upload. getErrorCode() is attachments_too_large, the same code the server returns for the 422.
RecadoException any other Base class; also the catch-all for unexpected non-2xx statuses.

Testing with the sandbox

A sandbox project lets your CI exercise the real send pipeline without touching production data or real inboxes. The API token is the routing: a sandbox token quietly captures everything it sends and unlocks the event simulator; a production token can't even see the simulator (it gets a bare 404). So the same code under test only needs a different RECADO_API_TOKEN.

The recipe is: send → read it back from messages() (the sandbox inbox) → simulate an event → assert.

Notes and safety properties:

Laravel integration

The package is auto-discovered (no manual provider/alias registration). It registers a container-bound RecadoClient singleton, a Recado facade, a recado mail transport and a recado notification channel — all driven by the same recado-sdk config.

Configuration

Publish the config file:

Then set the env vars (every key below maps to config/recado-sdk.php):

Resolve the client from the container:

The resilience knobs (RECADO_TIMEOUT, RECADO_RETRIES, RECADO_RETRY_BASE_DELAY, RECADO_RETRY_MAX_DELAY) are wired into the container-bound client automatically.

Connection config. RECADO_API_TOKEN is required — an empty token throws a Recado\Sdk\Exception\RecadoConfigurationException at construction. RECADO_BASE_URL is optional: it defaults to the canonical hosted API (https://api.recado.dev/v1; the legacy apex path https://recado.dev/api/v1 remains valid), so hosted users only set the token; self-hosted users override it. An explicitly empty base URL, the old placeholder base URL still throws, instead of silently sending to a dead host.

Mail transport (MAIL_MAILER=recado)

The package registers a recado mail driver, so you can route Laravel's Mail facade (and notifications, queued mailers, etc.) through the platform /send API without changing any mailing code.

Add a mailer entry to config/mail.php:

and select it:

Now every send flows through the API:

The transport maps the message to a single /send call (one recipient) or a /send/batch call (multiple recipients), reading the subject, HTML body and text body off the message.

Sending with a stored template

To render a platform template by slug instead of inline HTML, set the template headers on the underlying Symfony message from your Mailable. The transport then sends a template payload ({to, template, variables}) and ignores the inline subject/body:

Attachments

Attachments on a Mailable / Symfony message are mapped onto the /send attachments field and delivered by the platform. The behavior is driven by recado-sdk.mail.attachments (env RECADO_MAIL_ATTACHMENTS):

Mode Behavior
send (default) Map each attachment to {filename, content_type, content(base64)} and send it. An unnamed attachment gets the filename attachment plus an extension inferred from its media type (e.g. attachment.pdf).
fail Throw Recado\Sdk\Exception\UnsupportedFeatureException — the pre-1.4 fail-loud behavior for apps that never want attachments to leave through this transport.
ignore Log a warning and send the message without the attachments.

Platform limits (validated server-side, one guard duplicated client-side):

Behavior & limitations

The platform /send API is intentionally narrow; the transport adapts to it with explicit, documented behavior rather than silent surprises.

Notification channel

The SDK also registers a recado notification channel, so a Notification can deliver through the platform /send API by returning ['recado'] from via() and defining toRecado($notifiable).

toRecado() returns a Recado\Sdk\Laravel\Mail\RecadoMessage for full control. Inline mode uses subject()/html()/text():

Template mode renders a stored template with per-recipient variables:

Recipient routing precedence: an explicit RecadoMessage::to() wins, then routeNotificationFor('recado'), then routeNotificationFor('mail'), then a public $email property on the notifiable.

Other return types are accepted too: a plain /send payload array is used directly (its to/idempotency_key keys are honored, and an attachments key passes through to the API — see Attachments above for shape and limits), and an Illuminate\Contracts\Mail\Mailable is rendered to its subject + HTML only (its attachments are NOT carried over) — return a RecadoMessage for templates, a text part or an explicit idempotency key, or the array form for attachments.

The outcome semantics mirror the transport: a suppressed recipient is not a failure — a Recado\Sdk\Laravel\Events\MessageSuppressed event is dispatched and the send is skipped — while quota / sending-domain / any other API error is rethrown so Laravel marks the notification failed and retries per your queue policy.

A complete notification:

Facade

The package registers a Recado facade (auto-registered via package discovery) that proxies the same container-bound RecadoClient singleton — no separate configuration is needed:

Contributing / Development

Tests run entirely against a Guzzle MockHandler — no network access required.

Both commands run in CI (.github/workflows/sdk.yml in the source monorepo) on PHP 8.4 and 8.5 for every push and pull request, so a change that breaks the suite or the code style cannot land.

For how this package is split out of the monorepo into its own repository, tagged with SemVer and published to Packagist, see PUBLISHING.md.


All versions of recado-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
guzzlehttp/guzzle Version ^7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package recado/recado-php contains the following files

Loading the files please wait ...