Skip to content

Instantly share code, notes, and snippets.

@savepong
Created March 8, 2018 15:02
Show Gist options
  • Save savepong/9f2696549e25135906e5caa21773e3b0 to your computer and use it in GitHub Desktop.
Save savepong/9f2696549e25135906e5caa21773e3b0 to your computer and use it in GitHub Desktop.
Laravel 5.6 SendGrid Integate
# installed with composer
composer require s-ichikawa/laravel-sendgrid-driver
# Add the sendgrid service provider in config/app.php:
'providers' => [
Sichikawa\LaravelSendgridDriver\SendgridTransportServiceProvider::class
];
# Config on .env
MAIL_DRIVER=sendgrid
SENDGRID_API_KEY='YOUR_SENDGRID_API_KEY'
# config/services.php (In using lumen, require creating config directory and file.)
'sendgrid' => [
'api_key' => env('SENDGRID_API_KEY'),
],
# Use in Mailable
<?
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' => [
[
'substitutions' => [
':myname' => 's-ichikawa',
],
],
],
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment