承接 biegalski-llc/laravel-mailgun-webhooks 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

biegalski-llc/laravel-mailgun-webhooks

Composer 安装命令:

composer require biegalski-llc/laravel-mailgun-webhooks

包简介

This package allows you to quick and easily integrate your Laravel application with Mailgun Webhooks thus allowing you to track the outgoing email status for each individual user. There is also an optional feature to receive alerts for specific mailgun events such as spam complaints and sending fail

README 文档

README

This package, Laravel-Mailgun-Webhooks, has been superseded by a new and improved solution: Notification-Tracker.

Notification-Tracker offers a more robust, flexible, and maintainable way to handle webhook notifications. We strongly encourage all users to migrate to the new package.

This repository will remain available for reference, but it will no longer be actively maintained.

Thank you for your understanding.

Mailgun Webhooks for Laravel

Tracking

This package allows you to quick and easily integrate your Laravel application with Mailgun Webhooks thus allowing you to track the outgoing email status for each individual user.

  • Log when an email was delivered to a specific user
  • Log when an email failed to send to a specific user
  • etc...

This may be useful information you want to display to your end users or to a certain subset of users (Managers, Moderators, Admins, etc...).

Email Content Storage

This package will also store the content of the emails sent if you need to reference them at any point in the future. There are many use-cases for why this information is valuable.

  • Verify a customers complaint with information in the email they received a few weeks ago
  • Validate that a customer isn't altering / falsifying an email to benefit their case
  • etc...

Alerts

This package allows gives you the ability to set it up so that you receive alerts for specific things. You have the ability to turn on and off the type of notifications you want to receive.

  • Get notified when an email fails to deliver to a user
  • Get notified when a user files a spam complaint
  • etc...

Installation Instructions

Lets begin the installation. First you'll need to install the package with composer.

composer require biegalski-llc/laravel-mailgun-webhooks

Next, you will want to publish the configuration and view files.

php artisan vendor:publish --tag=mailgun_webhook_config

php artisan vendor:publish --tag=mailgun_webhook_view

Migrations

Since the migrations for this package was made in 2019. They can cause problems with newer projects.
Using a user model for instance "App\Models\Customer" that was created after 2019. When running tests the migrations will be run on a mock database, which will cause the package migrations to be run before the customers table exist. The package migrations will try to create a relation to your user model. \

To circumvent this, you can publish the migrations and manually change the timestamps in the file names.

php artisan vendor:publish --tag=mailgun_webhook_migrations

DotEnv Configuration Options

Below you will find various options to configure this plugin to your needs.

Options

Turn on and off certain features of this package

MAILGUN_WEBHOOKS_OPTIONS_DISABLE_CONTENT=false
MAILGUN_WEBHOOKS_OPTIONS_DISABLE_FLAG=false
MAILGUN_WEBHOOKS_OPTIONS_DISABLE_TAG=false
MAILGUN_WEBHOOKS_OPTIONS_DISABLE_VARIABLE=false

Notifications

Turn on and off various notifications and set who these notifications send to.

MAILGUN_WEBHOOKS_ALERTS_TO=
MAILGUN_WEBHOOKS_ALERTS_FROM_EMAIL=
MAILGUN_WEBHOOKS_ALERTS_FROM_NAME=

MAILGUN_WEBHOOKS_TRIGGER_DELIVERED=false
MAILGUN_WEBHOOKS_TRIGGER_OPENED=false
MAILGUN_WEBHOOKS_TRIGGER_PERM_FAILURE=true
MAILGUN_WEBHOOKS_TRIGGER_SPAM=true
MAILGUN_WEBHOOKS_TRIGGER_TEMP_FAILURE=true
MAILGUN_WEBHOOKS_TRIGGER_UNSUBSCRIBE=true

Content Logging

Storing all content can quickly build up disk space used. Turn on and off various pieces of content to store. Only store what you need! body_html by default is true, the rest by default are false.

MAILGUN_WEBHOOKS_CONTENT_LOG_STRIP_HTML=false
MAILGUN_WEBHOOKS_CONTENT_LOG_STRIP_TEXT=false
MAILGUN_WEBHOOKS_CONTENT_LOG_BODY_HTML=true
MAILGUN_WEBHOOKS_CONTENT_LOG_BODY_PLAIN=false

Custom Database Connection

Storing all of these mailgun notifications in another database? Specify which database connection to use.

MAILGUN_WEBHOOKS_CUSTOM_DATABASE=null

User Model

By default - we reference the App\Users model to form the relationship. If you use a custom model or have made changes to the User model - you may need to add and edit these variables to your dotenv as well:

MAILGUN_WEBHOOKS_USER_TABLE_NAME=users
MAILGUN_WEBHOOKS_USER_TABLE_EMAIL=email
MAILGUN_WEBHOOKS_USER_TABLE_KEY=id
MAILGUN_WEBHOOKS_USER_TABLE_FPQN=App\Users

Signing Key

Mailgun allows you to set an HTTP webhook signing key, which can be different from the API key value set in the MAILGUN_SECRET environment variable used to connect to the Mailgun API for sending. This is especailly useful if you use Domain level sending API keys or have rotated the HTTP Webhook signing key. Defaults to the MAILGUN_SECRET value.

MAILGUN_WEBHOOKS_SIGNING_KEY=

After you've completed the configuration - lets re-cache it:

php artisan config:cache

Now, you'll need to run the database migrations:

php artisan migrate

And, finally, you'll need to add a middleware to the route middleware group. In app\Http\Kernel.php add the following line to the routeMiddleware group:

'mailgun_webhooks' => \Biegalski\LaravelMailgunWebhooks\Middleware\ValidateMailgunWebhook::class,

You're all set! Now you just need to add the API endpoints to the webhooks in your Mailgun account.

Add Webhooks In Mailgun

  1. Login
  2. Navigate to Sending -> Webhooks
  3. Click Add Webhook button
  4. Select the appropriate Event Type and input its corresponding API endpoint. Endpoints listed below:
Event Type Endpoint URL
Clicks https://domain.com/api/mg-webhooks/clicked
Delivered Messages https://domain.com/api/mg-webhooks/delivered
Opened Messages https://domain.com/api/mg-webhooks/opened
Permanent Failure https://domain.com/api/mg-webhooks/perm-failure
Spam Complaints https://domain.com/api/mg-webhooks/spam
Temporary Failure https://domain.com/api/mg-webhooks/temp-failure
Unsubscribes https://domain.com/api/mg-webhooks/unsubscribe

*Replace "https://domain.com" with your applications URL.

Usage

It starts collecting data and sending notifications after configuration is setup. You can dive deeper and extract or display this data. Usage steps for that coming soon!

Affiliations

I have no affiliation with Laravel or Mailgun. Both are just frequently used in projects I am involved in and this package fills a need across various projects.

Translations

There is currently 9 translations:

  • German
  • English
  • Spanish
  • French
  • Italian
  • Dutch
  • Portuguese
  • Russian
  • Polish

More languages coming soon!

If you're unsure how localization works in Laravel, please reference the documentation at https://laravel.com/docs/master/localization

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

biegalski-llc/laravel-mailgun-webhooks 适用场景与选型建议

biegalski-llc/laravel-mailgun-webhooks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 97.38k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2019 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「laravel」 「mailgun」 「webhooks」 「email delivery status」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 biegalski-llc/laravel-mailgun-webhooks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 biegalski-llc/laravel-mailgun-webhooks 我们能提供哪些服务?
定制开发 / 二次开发

基于 biegalski-llc/laravel-mailgun-webhooks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 97.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 3
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-09