oskargunther/sendgrid-bundle
最新稳定版本:1.5.10
Composer 安装命令:
composer require oskargunther/sendgrid-bundle
包简介
Integrates sendgrid-php with Symfony >=2.8 with extra message profiling
README 文档
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
统计信息
- 总下载量: 671
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-24