PHPackages                             mahrdanial/shwanix-mailer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. mahrdanial/shwanix-mailer

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

mahrdanial/shwanix-mailer
=========================

Laravel mail driver that sends messages through the Shwanix HTTP mail API (JSON POST) instead of SMTP.

v1.4.0(3w ago)120↓100%MITPHPPHP ^8.0

Since Apr 16Pushed 3w agoCompare

[ Source](https://github.com/mahrdanialahsan/shwanix-mailer)[ Packagist](https://packagist.org/packages/mahrdanial/shwanix-mailer)[ Docs](https://github.com/mahrdanialahsan/shwanix-mailer)[ RSS](/packages/mahrdanial-shwanix-mailer/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (7)Used By (0)

Shwanix Mailer for Laravel
==========================

[](#shwanix-mailer-for-laravel)

Send Laravel mail through the **Shwanix HTTP mail API** (JSON `POST`) instead of SMTP. Works with standard `Mail` facades, Mailables, and queues.

**Requirements:** PHP `^8.0`, Guzzle `^7.5`, Laravel **`^7.30` through `^12.0`** (see below).

**Laravel &amp; PHP:** Supports **Laravel 7.30+** through **12.x** (Composer cannot install this package on Laravel 7.0–7.29). Laravel **7** requires **PHP 8** via **7.30.x** for use with this package. Laravel **11+** needs PHP **^8.2** (framework requirement). Internally, **Laravel 7–8** use a SwiftMailer transport (`legacy/SwiftShwanixTransport.php`); **Laravel 9+** use Symfony Mailer (`ApiTransport`).

Installation
------------

[](#installation)

From your Laravel application root:

```
composer require mahrdanial/shwanix-mailer
```

The service provider is **auto-discovered**; you do not need to register it manually.

Publish the optional configuration file:

```
php artisan vendor:publish --tag=shwanix-mailer-config
```

This creates `config/shwanix-mail.php` (endpoint URL, API key, HTTP timeouts, SSL verification).

What `MAIL_MAILER=shwanix` does
-------------------------------

[](#what-mail_mailershwanix-does)

Laravel’s mail stack is driven by `config/mail.php`. The **`mailer`** (sometimes called “driver” in docs) decides **how** messages are sent: `smtp`, `log`, `array`, etc.

Setting **`MAIL_MAILER=shwanix`** tells Laravel to use this package’s custom transport. The provider registers it with `Mail::extend('shwanix', …)`, so the name **`shwanix`** must appear in your mailers config (see below). You can still use other mailers (`smtp`, `log`) for different messages via `Mail::mailer('smtp')`, etc.

Configuration
-------------

[](#configuration)

### 1. Environment (`.env`)

[](#1-environment-env)

Required:

```
MAIL_MAILER=shwanix
SHWANIX_MAIL_KEY=your-plain-secret
```

`SHWANIX_MAIL_KEY` is **required**. Use the plain secret registered for your app (validated server-side). It is sent as the **`api_key`** field in JSON (no attachments) or in **multipart/form-data** when files are attached.

Optional tuning (defaults are set in `config/shwanix-mail.php`):

```
SHWANIX_MAIL_TIMEOUT=30
SHWANIX_MAIL_CONNECT_TIMEOUT=10
SHWANIX_MAIL_VERIFY_SSL=true
```

The default API URL is defined in the published `config/shwanix-mail.php` file. Set `SHWANIX_MAIL_URL` in `.env` only when you need to override that value.

### 2. Mail config (`config/mail.php`)

[](#2-mail-config-configmailphp)

Register the `shwanix` mailer under `mailers`:

```
'mailers' => [
    // ...
    'shwanix' => [
        'transport' => 'shwanix',
    ],
],
```

To use Shwanix for **all** outgoing mail by default:

```
'default' => env('MAIL_MAILER', 'shwanix'),
```

Usage
-----

[](#usage)

Use Laravel’s mail API as usual. Ensure **`SHWANIX_MAIL_KEY`** is set in `.env` so requests authenticate with the Shwanix API.

```
use Illuminate\Support\Facades\Mail;

Mail::raw('Hello from Shwanix.', function ($message) {
    $message->to('user@example.com')
        ->subject('Test');
});

Mail::send('emails.welcome', $data, function ($message) {
    $message->to(['a@example.com', 'b@example.com'])
        ->cc('cc@example.com')
        ->subject('Welcome');
});
```

Explicit mailer:

```
Mail::mailer('shwanix')->send(...);
```

Behaviour
---------

[](#behaviour)

FeatureBehaviourRecipients**`to`**: one string (comma-separated if multiple). **`cc` / `bcc`**: omitted when empty; otherwise a **string** for one address or a **JSON array** for several (matches the Shwanix API). Logs include **`recipient_count`**.BodyPrefers HTML; otherwise plain text.AttachmentsWith attachments: **`multipart/form-data`** with `attachments[]` file parts (decoded from Symfony/Swift parts). Without attachments: **`application/json`** with optional `attachments` as base64 objects.Success`info` log with `recipient_count` and HTTP status.FailureNon-2xx HTTP, Guzzle errors, or JSON `{ "status": false, "message": "..." }` → `TransportException` and `error` logs.### HTTP payload

[](#http-payload)

- **No attachments:** `POST` as **`application/json`** with `api_key`, `to`, `subject`, `body`, and optional `cc` / `bcc` (string or array of emails per the API). No `attachments` key when there are none.
- **With attachments:** `POST` as **`multipart/form-data`**: `api_key`, `to`, `subject`, `body`, optional `cc` / `bcc` (string or repeated `cc[]` / `bcc[]` parts), and binary **`attachments[]`** parts (filename + Content-Type from the mail part).

Responses are still treated as JSON when the server returns a JSON body (e.g. `{ "status": true }`).

Implementation note (transport base class)
------------------------------------------

[](#implementation-note-transport-base-class)

- **Laravel 9+:** `MailManager` uses Symfony Mailer. `ApiTransport` extends `Symfony\Component\Mailer\Transport\AbstractTransport`, like Laravel’s SES transport.
- **Laravel 7–8:** Mail uses SwiftMailer. A dedicated `SwiftShwanixTransport` extends `Illuminate\Mail\Transport\Transport` and is loaded only on those versions (see `legacy/SwiftShwanixTransport.php`).

Releasing
---------

[](#releasing)

Tag a stable version so Composer can resolve a default release:

```
git tag v1.0.0
git push origin v1.0.0
```

Then install with:

```
composer require mahrdanial/shwanix-mailer
```

License
-------

[](#license)

MIT.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance95

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

6

Last Release

26d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce50ae7ee6b7860b2c3d0621e7c5678802c1ea98b1c316d94be1a6884637e989?d=identicon)[mahrdanial](/maintainers/mahrdanial)

---

Top Contributors

[![mahrdanialahsan](https://avatars.githubusercontent.com/u/66950012?v=4)](https://github.com/mahrdanialahsan "mahrdanialahsan (9 commits)")

---

Tags

laravelmaillaravel-packagemailerhttp apishwanix

### Embed Badge

![Health badge](/badges/mahrdanial-shwanix-mailer/health.svg)

```
[![Health](https://phpackages.com/badges/mahrdanial-shwanix-mailer/health.svg)](https://phpackages.com/packages/mahrdanial-shwanix-mailer)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21764.8M1.6k](/packages/drupal-core)[illuminate/http

The Illuminate Http package.

13137.2M6.4k](/packages/illuminate-http)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M395](/packages/drupal-core-recommended)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M506](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
