nasimail/laravel-client

Laravel client package for NasiMail with API and Laravel Mail drivers.

Maintainers

Package info

github.com/Hostnasi-Technonologies/nasimail

pkg:composer/nasimail/laravel-client

Statistics

Installs: 33

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.6 2026-06-07 19:16 UTC

This package is auto-updated.

Last update: 2026-06-07 19:18:09 UTC


README

Tests

This package provides a Laravel client with two delivery drivers:

  • api: send messages to a NasiMail API instance via HTTP.
  • mail: send using Laravel's mail transport (MAIL_MAILER, etc.).

Supported Laravel versions: 8.x to 12.x.

Note: the custom MAIL_MAILER=nasimail transport is available on Laravel 9+. On Laravel 8, use the package api or mail driver via NasiMailClient.

Docs

  • Changelog: CHANGELOG.md
  • Wiki: WIKI.md

Testing

Run tests locally:

composer install
./vendor/bin/phpunit

CI validates Laravel 8 through 12 with a PHP/Laravel matrix:

  • Laravel 8.83 on PHP 8.1
  • Laravel 9.52 on PHP 8.1
  • Laravel 10.48 on PHP 8.2
  • Laravel 11.x on PHP 8.3
  • Laravel 12.x on PHP 8.4

Install in this monorepo

  1. Add a path repository in your app composer.json:
{
  "repositories": [
    {
      "type": "path",
      "url": "packages/nasimail",
      "options": { "symlink": true }
    }
  ]
}
  1. Require the package:
composer require nasimail/laravel-client:*
  1. Publish config:
php artisan vendor:publish --tag=nasimail-client-config

Config

Set in .env:

NASIMAIL_DRIVER=api
NASIMAIL_BASE_URL=https://nasimail.hostnasi.com
NASIMAIL_SECRET_KEY=sk_live_xxx

For Laravel mail transport mode:

NASIMAIL_DRIVER=mail
# optional override, otherwise uses your default Laravel mailer
NASIMAIL_MAILER=log

For custom transport mode via Laravel Mail:

MAIL_MAILER=nasimail
NASIMAIL_BASE_URL=https://nasimail.hostnasi.com
NASIMAIL_SECRET_KEY=sk_live_xxx

The package now registers a default mail.mailers.nasimail entry automatically. If your app overrides config/mail.php, you can add this explicitly:

'mailers' => [
  // ...
  'nasimail' => [
    'transport' => 'nasimail',
    'base_url' => env('NASIMAIL_BASE_URL'),
    'secret_key' => env('NASIMAIL_SECRET_KEY'),
    'timeout' => env('NASIMAIL_TIMEOUT', 10),
  ],
],

Usage

use NasiMail\Laravel\NasiMailClient;

$response = app(NasiMailClient::class)->send([
    'from' => 'hello@example.com',
    'to' => ['user@example.com'],
    'subject' => 'Hello',
    'text' => 'Hi there',
]);

Troubleshooting

If you see Mailer [nasimail] is not defined:

  1. Ensure the package service provider is loaded.
  2. Ensure .env includes:
MAIL_MAILER=nasimail
NASIMAIL_BASE_URL=https://nasimail.hostnasi.com
NASIMAIL_SECRET_KEY=sk_live_xxx
  1. Clear cached configuration:
php artisan config:clear
php artisan cache:clear