robriggen / SendGrid

SendGrid bundle for Laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SendGrid Bundle

Bundled up SendGrid PHP library for Laravel. SendGrid is a cloud-based email service which allows you to send emails from your applications in a reliable way.

For documentation and examples see the sendgrid-php library or README.git file in the bundle.

Installation

php artisan bundle:install sendgrid

Bundle Registration

Add the following to your application/bundles.php file:

'sendgrid' => array(
    'auto' => true
),

You will also need to add your username and password in config/options.php

Usage

The library has been modified to use a config file for username & password so you don't need to use it every time. Please keep this in mind when following examples from the original documentation.

Following example will get you started, shamelessly copied from the sendgrid-php docs.

$sendgrid = new SendGrid('username', 'password'); // This is original
$sendgrid = new SendGrid(); // For Laravel bundle users

Create a new SendGrid Mail object and add your message details

$mail = new SendGrid\Mail();
$mail->addTo('foo@bar.com')->
       setFrom('me@bar.com')->
       setSubject('Subject goes here')->
       setText('Hello World!')->
       setHtml('<strong>Hello World!</strong>');

Send it using the API of your choice (SMTP or Web)

$sendgrid->smtp->send($mail);

Or

$sendgrid->web->send($mail);

About

SendGrid bundle for Laravel