Go to file
Maxime 1d1b998a0b Update 'config/bmail.php' 2020-05-07 15:38:12 +02:00
config Update 'config/bmail.php' 2020-05-07 15:38:12 +02:00
src Notifiable 2020-04-29 18:02:40 +02:00
.gitignore Adding Guzzle 2020-04-09 10:56:55 +02:00
README.md Update 'README.md' 2020-05-07 15:37:48 +02:00
composer.json Return type hints, psr, readme.md, composer.json 2020-04-27 17:53:30 +02:00
composer.lock Adding Guzzle 2020-04-09 10:56:55 +02:00

README.md

laravel-bmail

The Bluescale Mail package allows you to send Bluescale Mail templates using Laravel notifications system.

Installation

First in your composer.json, add:

"require": {
        "bluescale/laravel-bmail": "dev-master"
}
"repositories": [
        {
            "type": "vcs",
            "url": "https://git.bluesquare.io/bluescale/laravel-bmail"
        }
]

Next update your package:

composer update bluescale/laravel-bmail

Then publish the assets from your provider:

php artisan vendor:publish

Finally, copy your API key from Bluescale Mail (Templates section), and add it in your .env:

BMAIL_API_KEY=your_api_key

You may also want to use your own API:

BMAIL_API_URL=https://bluescale.email/api/project/template/send

Usage

First, create a new notification or use an existing one:

php artisan make:notification MyAwesomeNotification

Add BMailChannel in the via() method:

return [BMailChannel::class];

Then, create a 'toTemplate()' method, in which you specify your template fields :

public function toTemplate($notifiable)
{
    return (new BMailTemplate("my-template-id"))
        ->sender("john.doe@gmail.com", "John OPTIONAL") // OPTIONAL
        ->replyTo("jean.grey@gmail.com", "Jean OPTIONAL") // OPTIONAL
        ->recipients([
            [
                "elvis@gmail.com", [
                    "name" => "Elvis" // OPTIONAL,
                    "parameters" => ["key" => "value"] // OPTIONAL
                ]
            ],
            [
                "robert@gmail.com"
            ]
        ])
        ->addRecipient("edward@gmail.com") // OPTIONAL
        ->parameters(["key" => "value", "key" => "value"]) // OPTIONAL
        ->addParameter("key", "value") // OPTIONAL
        ;
}

The $notifiable is automaticaly added as recipient.

In your controller, you can now send your template:

User::first()->notify(new MyAwesomeNotification);