This page documents every public class and interface exposed by theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/yugo412/laravel-maily/llms.txt
Use this file to discover all available pages before exploring further.
yugo/laravel-maily package, extracted directly from source. Use it as the authoritative reference when integrating the transport, listening to delivery events, or handling errors in your Laravel application.
MailyTransport
| Detail | Value |
|---|---|
| Namespace | Yugo\Maily |
| Extends | Symfony\Component\Mailer\Transport\AbstractTransport |
| File | src/MailyTransport.php |
MailyTransport is the core driver. It bridges Laravel’s Mail facade with the Maily.id HTTP API by implementing Symfony Mailer’s AbstractTransport contract.
__toString(): string
Returns the string 'maily', which is the transport identifier registered with Laravel’s mailer system. This name is what you set as MAIL_MAILER=maily in your .env file.
doSend(SentMessage $message): void
Executes email delivery. This method is called internally by Symfony Mailer and should not be invoked directly. The following sequence occurs on each call:
- Reads
services.maily.keyfrom config; throwsMailyExceptionif absent. - Converts the
SentMessageto aSymfony\Component\Mime\Emailobject viaMessageConverter. - Throws
MailyExceptionif more than oneTorecipient is present. - Sends an authenticated
POST /api/v1/emails/sendrequest using Laravel’sHttpclient, with the configured retry policy and timeout. - Throws
MailyTransportExceptionif the response status is non-2xx, including any validation details from the API. - Dispatches
MailySentEventon success. - Catches any
ConnectionExceptionthat survives all retries and re-throws it asMailyTransportException.
API call performed by doSend
Endpoint — POST /api/v1/emails/send
Authentication — an X-API-Key header containing your Maily API key is attached to every request.
Request body fields
Sender address. Formatted as
"Name <email>" when a display name is present, or plain email otherwise. Sourced from the mail’s From header.Single recipient address. Formatted identically to
from. Only one recipient is accepted per request; passing more than one throws MailyException before the HTTP call is made.Email subject line, taken from the message’s
Subject header.HTML body of the email.
null when the message has no HTML part.Plain-text body of the email.
null when the message has no text part.MailyServiceProvider
| Detail | Value |
|---|---|
| Namespace | Yugo\Maily |
| Extends | Illuminate\Support\ServiceProvider |
| File | src/MailyServiceProvider.php |
boot(): void
Performs two actions when the application boots:
- Injects mailer config — merges
mail.mailers.maily(['transport' => 'maily']) into the runtime configuration so Laravel recognisesmailyas a valid mailer without requiring aconfig/mail.phpchange. - Registers the transport — calls
Mail::extend('maily', ...)to bind a factory closure that returns a freshMailyTransportinstance whenever themailymailer is resolved.
MailyServiceProvider is listed under extra.laravel.providers in composer.json, so it is auto-discovered by Laravel’s package discovery mechanism. You do not need to add it manually to config/app.php.MailySentEvent
| Detail | Value |
|---|---|
| Namespace | Yugo\Maily\Events |
| File | src/Events/MailySentEvent.php |
| Traits | Dispatchable, InteractsWithSockets, SerializesModels |
MailyTransport::doSend() after every successful API response. Listen to this event to log delivery IDs, feed analytics dashboards, or monitor API quota usage.
Constructor properties
All properties are declaredpublic readonly and are populated directly from the Maily API JSON response.
Delivery ID assigned by the Maily API. Use this value to correlate log entries or trace a specific send in the Maily dashboard.
Delivery status string returned by the API at the time of the request — for example,
"queued".Human-readable confirmation message from the API — for example,
"Email queued for delivery".Full decoded JSON response body from the API. Useful when you need fields beyond
id, status, and message without a separate API lookup.broadcastOn(): array
Returns a single-element array containing a PrivateChannel named 'maily-event'. If you have Laravel Echo configured and wish to receive delivery notifications in real time, subscribe to this private channel.
Example listener
MailyException
| Detail | Value |
|---|---|
| Namespace | Yugo\Maily\Exceptions |
| Extends | Exception |
| File | src/Exceptions/MailyException.php |
MailyException in your application indicates a problem you can correct in code or configuration — not a transient network failure.
Thrown when:
- The
services.maily.keyconfiguration value is empty or missing — message:"Missing Maily API key. Please set services.maily.key configuration." - More than one recipient address is present in the
Tofield — message:"Maily currently only supports a single recipient."
MailyTransportException
| Detail | Value |
|---|---|
| Namespace | Yugo\Maily\Exceptions |
| Extends | Symfony\Component\Mailer\Exception\TransportException |
| File | src/Exceptions/MailyTransportException.php |
TransportException, Laravel’s mailer infrastructure treats it as a delivery-layer failure.
Thrown when:
- The Maily API returns a non-2xx HTTP status. The exception message includes the status code, the
errorfield from the response body, and any field-leveldetailsvalidation messages. - A
ConnectionExceptionis caught after all configured retry attempts have been exhausted — message:"Could not connect to the Maily API."