tystr / sendgrid-bundle
A bundle for integrating the sendgrid php library into the Symfony2 framework
Installs: 10 687
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 5
Open Issues: 3
Type:symfony-bundle
Requires
- phpoption/phpoption: ~1.4
- sendgrid/sendgrid: *
- symfony/framework-bundle: ~2.2
Requires (Dev)
- phpunit/phpunit: *
- symfony/browser-kit: ~2.2
- symfony/finder: ~2.2
- symfony/monolog-bundle: ~2.2
This package is not auto-updated.
Last update: 2024-10-26 16:49:06 UTC
README
A simple bundle for integrating the sendgrid php library into the Symfony2 framework.
Installation
Composer
Require the package with the following command:
$ composer.phar require tystr/sendgrid-bundle
Configuration
Enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
new Tystr\Bundle\SendgridBundle\TystrSendgridBundle(),
Add the following to your configuration file:
tystr_sendgrid:
username: YOUR_SENDGRID_USERNAME
password: YOUR_SENDGRID_PASSWORD
Usage
Retrieve the service like so:
$sendgrid = $this->get('tystr_sendgrid.sendgrid');
See the Sendgrid Documentation for more information.
WebHooks
The bundle supports sendgrid webhooks.
Add the bundles routing to your application
# in app/config/routing.yml sendgrid_hooks: resource: "@TystrSendgridBundle/Resources/config/routing.xml"
Listen to any of the hook events
<service id="acme_sendgrid_listener" class="Acme\Bundle\SendgridListener"> <tag name="kernel.event_listener" event="sendgrid.bounce" method="onEmailBounce" /> </service>
namespace Acme\Bundle; use Tystr\Bundle\SendgridBundle\Event\WebHookEvent; class SendgridListener { public function onEmailBounce(WebHookEvent $event) { $this->logger->info('Address bounced: ' . $event-getEmail()->getOrElse('unknownEmail')); } }
Register the webhook
In the sendgrid interface, register the URL http://yourApp.com/__tystr/sendgrid
as the webhook.