Fluent Mailjet APIΒ v3 integration & mail transport for Laravel.
Send transactional mail through the Laravel Mail facade, or talk to the full Mailjet
REST API β contacts, lists, campaigns, templates and webhooks β with an expressive wrapper.
- Features
- Requirements
- Installation
- Configuration
- Sending mail with the Mailjet transport
- Using the Mailjet API
- Optional service providers
- Sandbox mode
- Documentation
- Testing
- Contributing
- License
- π¨ Drop-in mail transport β set one env var and every
Mailable/Notificationgoes through Mailjet. - π§© Full API v3 wrapper β low-level
get/post/put/deleteplus high-level helpers, built on the officialmailjet/mailjet-apiv3-phpclient. - ποΈ Resource managers β dedicated, injectable services for contacts, lists, metadata, campaigns, campaign drafts, templates and event callbacks.
- π§ͺ Sandbox mode β validate payloads in CI and local development without sending a single email.
- β‘ Zero-config setup β package auto-discovery registers the provider and
Mailjetfacade for you.
| Package | Supported versions |
|---|---|
| PHP | 7.4 Β· 8.x |
| Laravel | 9.x β 13.x |
| Symfony Mailer / Mailjet Mailer | 6.x Β· 7.x Β· 8.x |
composer require mailjet/laravel-mailjetThat's it. Package auto-discovery wires up the
MailjetServiceProvider and the Mailjet facade automatically.
Manual registration (only if auto-discovery is disabled)
Laravel 11 and newer β bootstrap/providers.php:
use Mailjet\LaravelMailjet\MailjetServiceProvider;
return [
App\Providers\AppServiceProvider::class,
MailjetServiceProvider::class,
];Laravel 10 and older β config/app.php:
'providers' => [
// ...
Mailjet\LaravelMailjet\MailjetServiceProvider::class,
],
'aliases' => [
// ...
'Mailjet' => Mailjet\LaravelMailjet\Facades\Mailjet::class,
],Grab your API key and secret from the Mailjet account settings.
1. Add your credentials to .env:
MAILJET_APIKEY=your_api_key
MAILJET_APISECRET=your_api_secret
MAIL_FROM_ADDRESS=you@example.com
MAIL_FROM_NAME="Your App"
# Optional β process requests without actually sending
MAILJET_SANDBOX=false2. Register the service in config/services.php:
'mailjet' => [
'key' => env('MAILJET_APIKEY'),
'secret' => env('MAILJET_APISECRET'),
// filter_var keeps the "true"/"false" env string honest (handy in Docker)
'sandbox' => filter_var(env('MAILJET_SANDBOX', false), FILTER_VALIDATE_BOOLEAN),
],Need to tune the API URL, version, or the transactional/common/v4 clients? See the full configuration reference.
1. Select the transport in .env:
MAIL_MAILER=mailjetLaravel 6 and older use the
MAIL_DRIVERkey instead.
2. Declare the mailer in config/mail.php:
'mailers' => [
// ...
'mailjet' => [
'transport' => 'mailjet',
],
],3. Send as usual β no Mailjet-specific code required:
use Illuminate\Support\Facades\Mail;
Mail::to($user)->send(new InvoicePaid($invoice));Make sure the from address is a verified Mailjet sender. More patterns (Mailjet templates, variables, custom headers) live in the examples guide.
Import the facade:
use Mailjet\LaravelMailjet\Facades\Mailjet;Mailjet::get($resource, $args, $options);
Mailjet::post($resource, $args, $options);
Mailjet::put($resource, $args, $options);
Mailjet::delete($resource, $args, $options);Every call returns a Mailjet\Response, or throws a
Mailjet\LaravelMailjet\Exception\MailjetException on an API error.
Filter arguments are documented in the Mailjet API reference.
Mailjet::getAllLists($filters);
Mailjet::createList($body);
Mailjet::getListRecipients($filters);
Mailjet::getSingleContact($id);
Mailjet::createContact($body);
Mailjet::createListRecipient($body);
Mailjet::editListrecipient($id, $body);$client = Mailjet::getClient(); // the underlying \Mailjet\Client instanceEach Mailjet resource has a focused, injectable manager. Register only the providers you use
in config/app.php (or bootstrap/providers.php on Laravel 11+):
| Service provider | Manages | Contract |
|---|---|---|
Providers\ContactsServiceProvider |
Contacts, incl. deletion (API v4) | ContactsV4Contract |
Providers\ContactsListServiceProvider |
Contact lists | ContactsListContract |
Providers\ContactMetadataServiceProvider |
Contact properties / metadata | ContactMetadataContract |
Providers\CampaignServiceProvider |
Campaigns | CampaignContract |
Providers\CampaignDraftServiceProvider |
Campaign drafts | CampaignDraftContract |
Providers\TemplateServiceProvider |
Templates | TemplateServiceContract |
Providers\EventCallbackUrlServiceProvider |
Event (webhook) callback URLs | EventCallbackUrlContract |
// config/app.php
'providers' => [
// ...
Mailjet\LaravelMailjet\Providers\ContactsServiceProvider::class,
],Then resolve the manager wherever you need it:
use Mailjet\LaravelMailjet\Services\ContactsV4Service;
public function handle(ContactsV4Service $contacts)
{
$contacts->delete(351406781);
}With MAILJET_SANDBOX=true, Mailjet validates the request and returns a successful
response without delivering any email β ideal for staging environments and automated tests.
MAILJET_SANDBOX=trueDetails in the configuration reference.
| Resource | Link |
|---|---|
| Configuration reference | docs/configuration.md |
| Examples (campaigns, templates, Mailables) | docs/usage.md |
| Full docs site | https://mailjet.github.io/laravel-mailjet/ |
| Mailjet API v3 | https://dev.mailjet.com/ |
| PHP API client | https://github.com/mailjet/mailjet-apiv3-php |
composer install
bin/phpunitIssues and pull requests are welcome β see CONTRIBUTING.md.
Released under the MIT License.