定制 kenyroot/laravel-ses 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kenyroot/laravel-ses

Composer 安装命令:

composer require kenyroot/laravel-ses

包简介

Allows you to track opens, deliveries, bounces, complaints and clicked links when sending emails through Laravel and Amazon SES

README 文档

README

A Laravel 5.5+ Package that allows you to get simple sending statistics for emails you send through SES, including deliveries, opens, bounces, complaints and link tracking.

Install via composer

Add to composer.json

composer require oliveready7/laravel-ses

Make sure your app/config/services.php has SES values set

'ses' => [
    'key' => your_ses_key,
    'secret' => your_ses_secret,
    'domain' => your_ses_domain,
    'region' => your_ses_region,
],

Important to note that if you're using an IAM, it needs access to SNS (for deliveries, bounces and complaints) as well as SES

Make sure your mail driver located in app/config/mail.php is set to 'ses'

Publish public assets

php artisan vendor:publish --tag=public --force

Migrate the package's database tables

php artisan migrate

Optionally you can publish the package's config (laravelses.php)

php artisan vendor:publish --tag=config

Config Options

  • aws_sns_validator - whether the package uses AWS's SNS validator for inbound SNS requests. Default = false

Run command in production to setup Amazon email notifications to track bounces, complaints and deliveries. Make sure in your configuration your app URL is set correctly.

If your application uses the http protocol instead of https add the --http flag to this command

php artisan setup:sns

Usage

To send an email with all tracking enabled

SesMail::enableAllTracking()
    ->to('hello@example.com')
    ->send(new Mailable);

All tracking allows you to track opens, bounces, deliveries, complaints and links

You can, of course, disable and enable all the tracking options

SesMail::disableAllTracking();
SesMail::disableOpenTracking();
SesMail::disableLinkTracking();
SesMail::disableBounceTracking();
SesMail::disableComplaintTracking();
SesMail::disableDeliveryTracking();


SesMail::enableAllTracking();
SesMail::enableOpenTracking();
SesMail::enableLinkTracking();
SesMail::enableBounceTracking();
SesMail::enableComplaintTracking();
SesMail::enableDeliveryTracking();

The batching option gives you the chance to group emails, so you can get the results for a specific group

SesMail::enableAllTracking()
    ->setBatch('welcome_emails')
    ->to('hello@example.com')
    ->send(new Mailable);

You can manipulate the results manually by querying the database. Or you can use functions that come with the package.

SesMail::statsForBatch('welcome_emails');

//example result
[
    "send_count" => 8,
    "deliveries" => 7,
    "opens" => 4,
    "bounces" => 1,
    "complaints" => 2,
    "click_throughs" => 3,
    "link_popularity" => collect([
        "https://welcome.page" => [
            "clicks" => 3
        ],
        "https://facebook.com/brand" => [
            "clicks" => 1
        ]
    ])
]

Send count = number of emails that were attempted

Deliveries = number of emails that were delivered

Opens = number of emails that were opened

Complaints = number of people that put email into spam

Click throughs = number of people that clicked at least one link in your email

Link Popularity = number of unique clicks on each link in the email, ordered by the most clicked.

API INFO

Data always has the 'success' key indicating whether the request was successful or not

400 bad request = validation for the endpoint failed

404 = something in your query was not found

422 = any other error that might have occurred

GET /laravel-ses/api/has/bounced/{email}

Parameters - none

Response

    {
        "success": "true",
        "bounced": "true",
        "bounces": [
            {
                "message_id":"7a",
                "sent_email_id": "1",
                "type": "Permanent",
                "email": "harrykane@gmail.com",
                "bounced_at": "2018-01-01 12:00:00"
            }
        ]
    }

GET /laravel-ses/api/has/complained/{email}

Parameters - none

Response

    {
        "success": "true",
        "complained": "true",
        "complaints": [
            {
                "message_id":"8b",
                "sent_email_id": "23",
                "type": "abuse",
                "email": "wanyama@hotmail.com",
                "complained_at": "2018-01-02 09:12:00"
            }
        ]
    }

GET /laravel-ses/api/stats/batch/{batchName}

Parameters - none

Response

    {
        "success": "true",
        "data": {
            "success":true,
            "data": {
                "send_count":0,
                "deliveries":0,
                "opens":0,
                "bounces":0,
                "complaints":0,
                "click_throughs":0,
                "link_popularity":[]
            }
        }
    }

GET /laravel-ses/api/stats/email/{email}

Parameters - none

Response

{
"success": true,
"data": {
    "counts": {
        "sent_emails": 3,
        "deliveries": 2,
        "opens": 1,
        "bounces": 1,
        "complaints": 1,
        "click_throughs": 2
    },
    "data": {
        "sent_emails": [
            {
                "id": 1,
                "message_id": "d3e2028a324fde23363ec3a073ecd436@swift.generated",
                "email": "something@gmail.com",
                "batch": "welcome_emails",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": "2017-08-25 07:58:40",
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            },
            {
                "id": 9,
                "message_id": "b623bf23064c088fa044a58f22ddacad@swift.generated",
                "email": "something@gmail.com",
                "batch": "win_back",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": "2017-08-25 07:58:40",
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            },
            {
                "id": 10,
                "message_id": "ec100dcd13ce91b6b28002173564d1b9@swift.generated",
                "email": "something@gmail.com",
                "batch": "june_newsletter",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": null,
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            }
        ],
        "deliveries": [
            {
                "id": 1,
                "message_id": "d3e2028a324fde23363ec3a073ecd436@swift.generated",
                "email": "something@gmail.com",
                "batch": "welcome_emails",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": "2017-08-25 07:58:40",
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            },
            {
                "id": 9,
                "message_id": "b623bf23064c088fa044a58f22ddacad@swift.generated",
                "email": "something@gmail.com",
                "batch": "win_back",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": "2017-08-25 07:58:40",
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            }
        ],
        "opens": [
            {
                "id": 1,
                "sent_email_id": "1",
                "email": "something@gmail.com",
                "batch": "welcome_emails",
                "beacon_identifier": "bfd935de-2219-4f86-9bd3-24afd06cc37a",
                "url": "https://laravel-ses.com/laravel-ses/beacon/bfd935de-2219-4f86-9bd3-24afd06cc37a",
                "opened_at": "2018-03-18 10:28:26",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            }
        ],
        "bounces": [
            {
                "id": 3,
                "message_id": "b623bf23064c088fa044a58f22ddacad@swift.generated",
                "sent_email_id": "9",
                "type": "abuse",
                "email": "something@gmail.com",
                "complained_at": "2017-08-25 07:58:39",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            }
        ],
        "complaints": [
            {
                "id": 3,
                "message_id": "b623bf23064c088fa044a58f22ddacad@swift.generated",
                "sent_email_id": "9",
                "type": "abuse",
                "email": "something@gmail.com",
                "complained_at": "2017-08-25 07:58:39",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26"
            }
        ],
        "click_throughs": [
            {
                "id": 1,
                "link_identifier": "0f14e25d-4712-4a9a-be6b-b190dc1a31b3",
                "sent_email_id": "1",
                "original_url": "https://google.com",
                "batch": "welcome_emails",
                "clicked": "1",
                "click_count": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26",
                "message_id": "d3e2028a324fde23363ec3a073ecd436@swift.generated",
                "email": "something@gmail.com",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": "2017-08-25 07:58:40",
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1"
            },
            {
                "id": 1,
                "link_identifier": "c7933d15-8e22-41e7-9074-e327ee02cf1a",
                "sent_email_id": "1",
                "original_url": "https://superficial.io",
                "batch": "welcome_emails",
                "clicked": "1",
                "click_count": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26",
                "message_id": "d3e2028a324fde23363ec3a073ecd436@swift.generated",
                "email": "something@gmail.com",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": "2017-08-25 07:58:40",
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1"
            },
            {
                "id": 9,
                "link_identifier": "be2d0bc9-87b7-48cc-8b57-6b714bfc9d48",
                "sent_email_id": "9",
                "original_url": "https://google.com",
                "batch": "win_back",
                "clicked": "1",
                "click_count": "1",
                "created_at": "2018-03-18 10:28:26",
                "updated_at": "2018-03-18 10:28:26",
                "message_id": "b623bf23064c088fa044a58f22ddacad@swift.generated",
                "email": "something@gmail.com",
                "sent_at": "2018-03-18 10:28:26",
                "delivered_at": "2017-08-25 07:58:40",
                "complaint_tracking": "1",
                "delivery_tracking": "1",
                "bounce_tracking": "1"
            }
        ]
    }
}

kenyroot/laravel-ses 适用场景与选型建议

kenyroot/laravel-ses 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 kenyroot/laravel-ses 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-21