toastnz/sendgrid-mailer

SilverStripe SendGrid Mailer

Installs: 994

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 2

Open Issues: 3

Type:silverstripe-module

1.3.1 2019-11-18 02:29 UTC

This package is auto-updated.

Last update: 2020-09-18 05:07:59 UTC


README

Simple mailer module that uses SendGrid API to send emails.

Requirements

  • silverstripe/cms ^4.3.x
  • silverstripe/framework ^4.3.x
  • sendgrid/sendgrid ^7.3

Installation

composer require toastnz/sendgrid-mailer

Configuration

Add the following to your app.yml:

Toast\SSSendGrid\SendGridMailer:
  api_key: 'YOUR_SENDGRID_API_KEY'

Usage

Simply use the Email class provided by SilverStripe framework:

$email = new SilverStripe\Control\Email\Email();
$email->setFrom('from@example.com', 'John Doe');
$email->setTo('to@example.com', 'Jane Doe');
$email->setSubject('This is a test email');
$email->setBody('Hello there, this was sent using SendGrid');
$email->addAttachment('path/to/file.pdf', 'document.pdf');
$email->send();