Download the PHP package leadm/leadmail without Composer
On this page you can find all versions of the php package leadm/leadmail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leadm/leadmail
More information about leadm/leadmail
Files in leadm/leadmail
Package leadmail
Short Description Laravel SDK for leadMail email sending and verification service
License MIT
Homepage https://github.com/leadmnik/leadmail-sdk
Informations about the package leadmail
LeadMail SDK for Laravel
Laravel package for sending emails and verifying email addresses through the leadMail service.
Requirements
- PHP 8.2+
- Laravel 11, 12, or 13
Installation
Add these to your .env:
Then run the installer:
That's the whole setup. The command publishes the config, registers this app's
failure-webhook URL with the service, and writes the generated
LEADMAIL_WEBHOOK_SECRET into your .env — no secret to copy by hand. It runs
without prompts, so it's safe in CI/Ploi deploy hooks. See
Receiving Failure Webhooks for what it wires up.
If you only need sending/verification and not webhooks, you can skip the installer and just publish the config with
php artisan vendor:publish --tag=leadmail-config.
Configuration
Everything is configured by environment variables; the published
config/leadmail.php reads from them. All of these are optional and have
sensible defaults:
Usage
Send Emails via Mail Driver
Set leadmail as your mail driver in .env:
Then use Laravel's Mail facade as usual:
Send Emails via API
Verify Email Addresses
Validation Rule
Use the leadmail_verify rule in your form requests:
Get Allowed Sender Domains
Error Handling
Every API failure is raised as a typed exception so you can handle it reliably from the client side. LeadMail::verifyEmail() is the exception — it fails open (returns status: "unknown") so a verification outage never blocks sign-ups.
| Exception | When |
|---|---|
LeadM\LeadMail\Exceptions\LeadMailRequestException |
The service returned an error response (4xx/5xx). |
LeadM\LeadMail\Exceptions\LeadMailConnectionException |
The service could not be reached (DNS/connection/timeout). |
LeadM\LeadMail\Exceptions\LeadMailException |
Base class for both of the above; catch this to handle any failure. |
Idempotent calls (getDomains, verifyEmail) automatically retry transient failures (connection errors and 429/5xx) with exponential backoff. Sends are never retried automatically — a retry after a dropped connection could deliver the same email twice. Retry sends yourself via a queued job if you need to.
Receiving Failure Webhooks
leadMail POSTs a signed email.failed webhook to your app when a send ultimately fails. This works out of the box — no route or config required.
Setup: one command
With LEADMAIL_TOKEN set in your .env, run:
It runs without prompts (safe for Ploi/CI) and:
- publishes the config,
- registers your webhook URL with the leadMail service over the API (authenticated by your token), derived from
APP_URL+ the configured webhook route, - writes the generated
LEADMAIL_WEBHOOK_SECRETinto your.env.
That's it. The SDK auto-registers the receiving route (/webhooks/leadmail by default), which verifies the HMAC signature and logs every failure by default. Nothing else to wire up.
Options:
--url=https://your-app.com/custom/path— override the derived URL.--rotate— generate and store a fresh signing secret.
The secret is generated server-side and returned only once, at registration.
Custom handling
To do more than log (e.g. flag a contact, alert a channel), listen for the LeadMailWebhookReceived event:
Customising or replacing the route
LEADMAIL_WEBHOOK_ROUTE— change the path (keep it in sync with the registered URL vialeadmail:install).- Set
leadmail.webhook_routetonullto disable auto-registration and handle the request yourself withLeadMailWebhook::parse($request)(verifies the signature against the raw body, throwsInvalidWebhookSignatureExceptionon mismatch;verify()returns a boolean instead).
Multi-Tenancy
If your app uses stancl/tenancy, the SDK automatically includes the current tenant ID in API requests via the X-Tenant-Id header. Disable this with:
License
MIT
All versions of leadmail with dependencies
guzzlehttp/guzzle Version ^7.0
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/mail Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0