← All Resources
Ecosystem Package

Laravel Mailgun Client

A lightweight Laravel package that wraps the Mailgun API into a clean, idiomatic HTTP client. It handles email sending, mailing list management, and webhook retrieval — all with first-class Laravel support through facades and dependency injection.

April 03, 2026

Visit Resource

What it does

Laravel Mailgun Client abstracts away the raw Mailgun HTTP API into a structured Laravel integration. Instead of manually crafting HTTP requests or wiring up a generic Guzzle client, you get a purpose-built facade and service class ready to use in controllers, jobs, and console commands. The package covers the most common Mailgun workflows: sending custom emails, managing newsletter mailing lists, and inspecting registered webhooks.

Key Features

  • Simple Composer installation with automatic service provider registration
  • Facade and dependency injection support for flexible consumption
  • Send custom emails and newsletters through a clean interface
  • Full mailing list management: fetch lists, add/remove members, subscribe and unsubscribe users
  • Retrieve registered Mailgun webhooks programmatically
  • Value objects for mailing list data (name, address, member count, access level)
  • Mockery-compatible facade for clean unit testing

Use Cases

  • Newsletter distribution — programmatically send newsletters to Mailgun mailing lists without a third-party SaaS.
  • Subscriber management — sync your application's user model with Mailgun mailing lists, subscribing on registration and unsubscribing on account deletion.
  • Transactional email — send custom emails via Mailgun directly from jobs or service classes using familiar Laravel patterns.
  • Webhook inspection — verify which webhooks are registered on your Mailgun domain during debugging or deployment checks.

Quick Start

Install via Composer:

1composer require lartisan/laravel-mailgun-client

Publish the config and set your credentials in .env:

1MAILGUN_DOMAIN=mg.example.com
2MAILGUN_SECRET=key-xxxxxxxxxxxxxxxx
3MAILGUN_ENDPOINT=api.eu.mailgun.net

Send an email using the facade:

1use Lartisan\MailgunClient\Facades\Mailgun;
2 
3Mailgun::send([
4 'from' => 'hello@example.com',
5 'to' => 'user@example.com',
6 'subject' => 'Welcome!',
7 'html' => '<p>Thanks for signing up.</p>',
8]);

Manage a mailing list:

1// Fetch all mailing lists
2$lists = Mailgun::mailingLists();
3 
4// Add a member
5Mailgun::addMember('newsletter@mg.example.com', [
6 'address' => 'user@example.com',
7 'name' => 'Jane Doe',
8 'subscribed' => true,
9]);
10 
11// Unsubscribe a member
12Mailgun::unsubscribeMember('newsletter@mg.example.com', 'user@example.com');

Mock the facade in tests:

1use Lartisan\MailgunClient\Facades\Mailgun;
2 
3Mailgun::shouldReceive('send')->once()->andReturn(true);

Conclusion

Laravel Mailgun Client is a solid choice for Laravel applications that already use Mailgun and want a clean, testable integration without the overhead of a full email marketing platform. It keeps your codebase idiomatic and your Mailgun interactions easy to mock and maintain.

Reviews

No reviews yet. Be the first to leave one.

Sign in to leave a review.

Sign in

Newsletter

Get notified when new components and articles are published. No spam, just Filament goodness.

We will send you a confirmation link before you are subscribed.