oskargunther / sendgrid-bundle
Integrates sendgrid-php with Symfony >=2.8 with extra message profiling
1.5.10
2019-12-01 15:17 UTC
Requires
- php: >=7.1
- sendgrid/sendgrid: ~7
- symfony/config: >=2.8.30
- symfony/dependency-injection: >=2.8.30
- symfony/event-dispatcher: >=2.8.30
- symfony/http-foundation: >=2.8.30
- symfony/var-dumper: >=2.8.30
- symfony/yaml: >=2.8.30
Requires (Dev)
- symfony/framework-bundle: >=2.8.30
- symfony/profiler-pack: ^1.0
- dev-master
- 1.5.10
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.5
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-develop
This package is auto-updated.
Last update: 2025-03-29 00:40:36 UTC
README
Symfony >=2.8 SendGrid Bundle
Documentation
Features
- Configure sendgrid-php through yaml
- Disable delivery through parameter
- WebProfiler Extension
- WebHook events dispatcher
- Redirect all messages to specific address
Using the Bundle.
Installation:
composer require oskargunther/sendgrid-bundle
Add bundle to kernel:
class AppKernel extends Kernel { public function registerBundles() { $bundles = [ .... new OG\SendGridBundle\OGSendGridBundle(), ]; } }
Configuration:
- config.yml
og_send_grid: api_key: string disable_delivery: false # default false
- config_dev.yml
og_send_grid: web_profiler: true # default %kernel.debug% (enabled) redirect_to: test@test.com # default false
Usage:
use OG\SendGridBundle\Exception\SendGridException; $provider = $this->get('og_send_grid.provider'); $email = $provider->createMessage(); $email->setFrom("test@test.pl", "Example User"); $email->setSubject("Test subject"); $email->addTo("o.gunther@test.pl", "Example User"); $email->addContent("text/plain", "and easy to do anywhere, even with PHP"); $email->addContent("text/html", "<strongand easy to do anywhere, even with PHP</strong"); try { $messageId = $provider->send($email); } catch (SendGridException $e) { echo 'Caught exception: '. $e->getMessage() ."\n"; }
Working with SendGrid WebHook events
Configuration:
- Event subscriber:
use OG\SendGridBundle\Event\WebHookEvent; use OG\SendGridBundle\EventSubscriber\WebHookEventSubscriber; class WebHookSubcriber extends WebHookEventSubscriber { function onBounce(WebHookEvent $event) { $event->getWebHook()->getSmtpId(); } function onClick(WebHookEvent $event) { } function onDeferred(WebHookEvent $event) { } function onDelivered(WebHookEvent $event) { } function onDropped(WebHookEvent $event) { } function onGroupResubscribe(WebHookEvent $event) { } function onGroupUnsubscribe(WebHookEvent $event) { } function onOpen(WebHookEvent $event) { } function onProcessed(WebHookEvent $event) { } function onSpamreport(WebHookEvent $event) { } function onUnsubscribe(WebHookEvent $event) { } }
- routing.yml
sendgrid_webhook: path: /sendgrid/webhook controller: OGSendGridBundle:WebHook:dispatch
- services.yml
app.subscriber.send_grid: class: AppBundle\Subscriber\WebHookSubcriber tags: - { name: kernel.event_subscriber }
Profiling sent messages (even if delivery is disabled):
- Messages count
- sendgrid/sendgrid-php - execution time in miliseconds
- symfony/stopwatch events