Laravel's mail transport for SendinBlue
composer require webup/laravel-sendinblue:^2
Compatibility
Version | Laravel | Sendiblue Api |
---|---|---|
2.* | 5.5 and above | v3 |
1.1.* | 5.5 and above | v2 |
1.0.* | 5.0 - 5.4 | v2 |
config/app.php
'providers' => [
Webup\LaravelSendinBlue\SendinBlueServiceProvider::class,
],
config/services.php
'sendinblue' => [
// api-key or partner-key
'key_identifier' => env('SENDINBLUE_KEY_IDENTIFIER', 'api-key'),
'key' => env('SENDINBLUE_KEY'),
],
.env
MAIL_DRIVER=sendinblue
SENDINBLUE_KEY=your-access-key
Using the sendinblue()
method you may pass extra fields listed below. All fields are optional:
template_id
(integer)tags
(array)params
(array)
If you want to use the subject defined in the template, it's necessary to pass the SendinBlueTransport::USE_TEMPLATE_SUBJECT
placeholder in the subject()
. You may as well override the subject text here. Otherwise, without the subject()
method, the subject will be derived from the class name.
Mailable requires a view - pass an empty array in the view()
method.
use SendinBlue;
// ...
public function build()
{
return $this
->view([])
->subject(SendinBlueTransport::USE_TEMPLATE_SUBJECT) // use template subject
// ->subject('My own subject') // subject overridden
->sendinblue(
[
'template_id' => 84,
'tags' => ['offer'],
'params' => [
'FIRSTNAME' => 'John',
'LINK' => 'https://www.example.com',
'AMOUNT' => '29',
],
]
);
}
Params are accessbile in the SendinBlue template as:
{{ params.FIRSTNAME }}
{{ params.LINK }}
{{ params.AMOUNT }}
You may as well use param substitution in the subject field, eg.:
{{ params.FIRSTNAME }}, forgot your password?!
Note: Do not use hyphens '-' in the variable names. {{ params.FIRST_NAME }}
will work properly, but {{ params.FIRST-NAME }}
will fail. Source: sendinblue/APIv3-php-library#151