scullwm / mailhookbundle
用于捕获来自不同邮件服务的API webhook的捆绑包
Requires
- php: >=5.3.9
- symfony/framework-bundle: ~2.8|~3.0|~4.0|~5.0
Requires (Dev)
- atoum/atoum: dev-master
This package is auto-updated.
Last update: 2024-09-04 13:14:52 UTC
README
捕获来自各种API邮件服务的webhook,并直接获取相关用户。
特性
定义您的项目URL到您的邮件服务提供商(Mandrill、MailJet...),并将事件分发到您的应用程序中。
支持各种服务
- Campaign Monitor
- Mailgun
- Mailjet
- Mandrill
- Sendgrid
- Sparkpost
- 并添加您的自定义服务
示例用例
- 当邮件被标记为垃圾邮件时,禁用用户的通知。
- 如果上次发送的邮件被退回,向用户发送私信。
- 当创建新用户时,警告账户经理有关硬退信。
- 跟踪您自定义CRM中的邮件阅读和点击。
- 所有您想要的!
安装
将此包添加到您的composer.json文件中
"scullwm/mailhookbundle": "dev-master",
添加到app/AppKernel.php中
<?php public function registerBundles() { $bundles = array( ... new Swm\Bundle\MailHookBundle\SwmMailHookBundle(), ); ... return $bundles; }
配置
1) 编辑app/config.yml
swm_mail_hook: secretsalt: notSecret
2) 编辑app/routing.yml
swm_mailhook_controller: resource: "@SwmMailHookBundle/Controller/" type: annotation prefix: /
做得好!
使用它
前往您的电子邮件服务提供商,例如mandrillapp.com,并找到配置webhook的位置。检查您想要的钩子并设置URL如下
http://www.mywebsite.com/webhook/{secretSalt}/{serviceName}/catch
对于Mandrill没有配置,应该是这样的: http://www.mywebsite.com/webhook/notSecret/mandrill/catch
对于具有自定义secretSalt和mailjet服务的,应该是这样的: http://www.mywebsite.com/webhook/dDifXo26/mailjet/catch
触发的事件
- swm.mail_hook.event.open
- swm.mail_hook.event.send
- swm.mail_hook.event.click
- swm.mail_hook.event.soft_bounce
- swm.mail_hook.event.hard_bounce
- swm.mail_hook.event.deferral
- swm.mail_hook.event.spam
- swm.mail_hook.event.blocked
- swm.mail_hook.event.unsub
- swm.mail_hook.event.reject
- swm.mail_hook.event.other
提供的事件监听器
默认情况下,由DefaultHydrator触发简单的MailHookEvent。但如果您使用FosUserBundle,您可以使用FosUserHydrator来使用直接返回与电子邮件相关联的用户实体的UserMailHookEvent。
如果您使用FosUserBundle
已存在一个名为"swm_mailhook_user_catcher_for_service"的特殊路由:/ {secretSalt} / {service} / catchuser
它直接返回一个UserMailHookEvent,您可以在其中调用getUser()。
要查看基本示例,请参阅此链接: https://gist.github.com/ScullWM/8acea9c0e229ed76717f(使用JMS/di-extra-bundle可选)