2017 © Pedro Peláez
 

library laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

image

s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

  • Thursday, December 28, 2017
  • by s-ichikawa
  • Repository
  • 6 Watchers
  • 100 Stars
  • 242,525 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 22 Forks
  • 1 Open issues
  • 23 Versions
  • 17 % Grown

The README.md

Laravel SendGrid Driver

SymfonyInsight Build Status, (*1)

A Mail Driver with support for Sendgrid Web API, using the original Laravel API. This library extends the original Laravel classes, so it uses exactly the same methods., (*2)

To use this package required your Sendgrid Api Key. Please make it Here., (*3)

Compatibility

Laravel laravel-sendgrid-driver
9, 10, 11 ^4.0
7, 8 ^3.0
5, 6 ^2.0

Install (for Laravel)

Add the package to your composer.json and run composer update., (*4)

"require": {
    "s-ichikawa/laravel-sendgrid-driver": "^4.0"
},

or installed with composer, (*5)

$ composer require s-ichikawa/laravel-sendgrid-driver

Install (for Lumen)

Add the package to your composer.json and run composer update., (*6)

"require": {
    "s-ichikawa/laravel-sendgrid-driver": "^4.0"
},

or installed with composer, (*7)

$ composer require "s-ichikawa/laravel-sendgrid-driver"

Add the sendgrid service provider in bootstrap/app.php, (*8)

$app->configure('mail');
$app->configure('services');
$app->register(Sichikawa\LaravelSendgridDriver\MailServiceProvider::class);

unset($app->availableBindings['mailer']);

Create mail config files. config/mail.php, (*9)

<?php
return [
    'driver' => env('MAIL_DRIVER', 'sendgrid'),
];

Configure

.env, (*10)

MAIL_DRIVER=sendgrid
SENDGRID_API_KEY='YOUR_SENDGRID_API_KEY'
# Optional: for 7+ laravel projects
MAIL_MAILER=sendgrid 

config/services.php (In using lumen, require creating config directory and file.), (*11)

    'sendgrid' => [
        'api_key' => env('SENDGRID_API_KEY'),
    ],

config/mail.php, (*12)

    'mailers' => [
        'sendgrid' => [
            'transport' => 'sendgrid',
        ],
    ],

endpoint config

If you need to set custom endpoint, you can set any endpoint by using endpoint key. For example, calls to SendGrid API through a proxy, call endpoint for confirming a request., (*13)

    'sendgrid' => [
        'api_key' => env('SENDGRID_API_KEY'),
        'endpoint' => 'https://custom.example.com/send',
    ],

How to use

Every request made to /v3/mail/send will require a request body formatted in JSON containing your email’s content and metadata. Required parameters are set by Laravel's usually mail sending, but you can also use useful features like "categories" and "send_at"., (*14)

more info https://www.twilio.com/docs/sendgrid/api-reference/mail-send/mail-send, (*15)

Laravel 10, 11:, (*16)

<?
use Sichikawa\LaravelSendgridDriver\SendGrid;

class SendGridSample extends Mailable
{
    use SendGrid;

    public function envelope(): Envelope
    {
        $this->sendgrid([
                'personalizations' => [
                    [
                        'to' => [
                            ['email' => 'to1@gmail.com', 'name' => 'to1'],
                            ['email' => 'to2@gmail.com', 'name' => 'to2'],
                        ],
                        'cc' => [
                            ['email' => 'cc1@gmail.com', 'name' => 'cc1'],
                            ['email' => 'cc2@gmail.com', 'name' => 'cc2'],
                        ],
                        'bcc' => [
                            ['email' => 'bcc1@gmail.com', 'name' => 'bcc1'],
                            ['email' => 'bcc2@gmail.com', 'name' => 'bcc2'],
                        ],
                    ],
                ],
                'categories' => ['user_group1'],
            ]);
        return new Envelope(
            from:    'from@example.com',
            replyTo: 'reply@example.com',
            subject: 'example',
        );
    }
}

Laravel 9:, (*17)

<?
use Sichikawa\LaravelSendgridDriver\SendGrid;

class SendGridSample extends Mailable
{
    use SendGrid;

    public function build():
    {
        return $this
            ->view('template name')
            ->subject('subject')
            ->from('from@example.com')
            ->to(['to@example.com'])
            ->sendgrid([
                'personalizations' => [
                    [
                        'to' => [
                            ['email' => 'to1@gmail.com', 'name' => 'to1'],
                            ['email' => 'to2@gmail.com', 'name' => 'to2'],
                        ],
                        'cc' => [
                            ['email' => 'cc1@gmail.com', 'name' => 'cc1'],
                            ['email' => 'cc2@gmail.com', 'name' => 'cc2'],
                        ],
                        'bcc' => [
                            ['email' => 'bcc1@gmail.com', 'name' => 'bcc1'],
                            ['email' => 'bcc2@gmail.com', 'name' => 'bcc2'],
                        ],
                    ],
                ],
                'categories' => ['user_group1'],
            ]);
    }
}

Using Template Id

Illuminate\Mailer has generally required a view file. But in case of using template id, set an empty array at view function., (*18)

Laravel 10, 11:, (*19)

<?
    public function envelope(): Envelope
    {
        $this->sendgrid([
            'personalizations' => [
                [
                    'dynamic_template_data' => [
                        'title' => 'Subject',
                        'name'  => 's-ichikawa',
                    ],
                ],
            ],
            'template_id' => config('services.sendgrid.templates.dynamic_template_id'),
        ]);
        return new Envelope(
            from:    'from@example.com',
            replyTo: 'reply@example.com',
            subject: 'example',
        );
    }

Laravel 9:, (*20)

<?
    public function build():
    {
        return $this
            ->view('template name')
            ->subject('subject')
            ->from('from@example.com')
            ->to(['to@example.com'])
            ->sendgrid([
                'personalizations' => [
                    [
                        'dynamic_template_data' => [
                            'title' => 'Subject',
                            'name'  => 's-ichikawa',
                        ],
                    ],
                ],
                'template_id' => config('services.sendgrid.templates.dynamic_template_id'),
            ]);
    }

The Versions

28/12 2017

dev-master

9999999-dev

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

28/12 2017

2.0.2

2.0.2.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

28/12 2017

dev-dev

dev-dev

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

03/09 2017

2.0.1

2.0.1.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

01/09 2017

2.0.0

2.0.0.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

01/09 2017

dev-dev_2

dev-dev_2

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

10/08 2017

1.2.6

1.2.6.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

27/06 2017

1.2.5

1.2.5.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

27/05 2017

1.2.4

1.2.4.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

laravel sendgrid

15/04 2017

1.2.3

1.2.3.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

21/03 2017

1.2.2

1.2.2.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

30/01 2017

1.2.1

1.2.1.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

25/01 2017

1.2.0

1.2.0.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

12/01 2017

1.1.6

1.1.6.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

11/01 2017

1.1.5

1.1.5.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

19/12 2016

1.1.4

1.1.4.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

02/12 2016

dev-dev54

dev-dev54

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

14/11 2016

1.1.3

1.1.3.0

This library adds a 'sendgrid' mail driver to Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

19/10 2016

1.1.2

1.1.2.0

This liblary can add sendgrid driver into the laravel's mail configure.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

12/10 2016

1.1.1

1.1.1.0

This liblary can add sendgrid driver into the laravel's mail configure.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

05/09 2016

1.1.0

1.1.0.0

This liblary can add sendgrid driver into the laravel's mail configure.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

16/08 2016

1.0.0

1.0.0.0

This liblary can add sendgrid driver into the laravel's mail configure.

  Sources   Download

MIT

The Requires

 

The Development Requires

by shingo.ichikawa

22/03 2016

5.0.x-dev

5.0.9999999.9999999-dev

This liblary can add sendgrid driver into the laravel's mail configure.

  Sources   Download

The Requires

 

The Development Requires

by shingo.ichikawa