alezhu/laravel-notisend

Laravel email transport implementation via Notisend

v12.0.0 2025-03-02 22:02 UTC

This package is auto-updated.

Last update: 2025-03-04 14:17:43 UTC


README

Notisend Laravel driver

License Code coverage GitHub Tag Total Downloads PHP Version Require GitHub branch status Packagist Stars CI

Table of Contents

Installation

Requirements

  • Laravel 12.0+
  • PHP 8.2+
  • An API Key from Notisend

For Laravel version below 12 see corresponding branches

Setup

You can install the package via composer:

composer require alezhu/laravel-notisend

After that, you need to set NOTISEND_API_TOKEN in your .env file:

NOTISEND_API_TOKEN=

And set environment variable MAIL_MAILER in your .env file

MAIL_MAILER=mailersend

Or you can leave the default driver value and use 'notisend' via:

$mailer = Mail::mailer('notisend');

Also, double check that your FROM data is filled in .env:

MAIL_FROM_ADDRESS=app@yourdomain.com
MAIL_FROM_NAME="App Name"

Not necessary

Add Notisend as a Laravel Mailer in config/mail.php in mailers array:

'notisend' => [
    'transport' => 'notisend',
],

Also, you can config driver via mailers.notisend in config/mail.php:

 'mailers' => [
    ...
    'notisend' => [
        'transport' => 'notisend',
        'api_token' => env('NOTISEND_API_TOKEN'),
        'host' => env('NOTISEND_API_HOST', 'https://api.notisend.ru/v1'),
        'payment' => env('NOTISEND_PAYMENT', 'credit_priority'),    
    ],
    ...
  ]

Or you can publish configuration file notisend.php via Artisan:

php artisan vendor:publish --tag=notisend-config

and then change parameters in config/notisend.php file

Parameters in config/mail.php has priority before config/notisend.php

Usage

use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Mail;
use Tests\TestCase;

class ExampleTestManual extends TestCase
{
    /**
     * A basic test example.
     */
    public function test_notisend(): void
    {
        Mail::mailer('notisend')
            ->raw('Test mail', function (Message $message) {
            $message->to('info@example.com');
            $message->subject('Test mail');
        });
    }
}

Please refer to Laravel Mail documenation and NotiSend API documentation for more information.

Support and Feedback

In case you find any bugs, submit an issue directly here in GitHub.

The author of this repository is in no way affiliated with Notisend.

License

The MIT License (MIT)