ope-tech/laravel-ses
Composer 安装命令:
composer require ope-tech/laravel-ses
包简介
Track email engagement on any email sent out via SES using Laravel. Tracks opens, clicks, bounces, complaints, deliveries, and rejections. Can be used with transaction, marketing emails and notifications.
关键字:
README 文档
README
This package is current in BETA mode so please be prepared for breaking changes every now and then
Track open rates, deliveries bounce rates, complaints, link clicks and more for every single email you send via SES in your Laravel App.
Setup tracking in minutes by reading the installtion instructions below.
This package uses the SESV2Client to leverage configuration sets and SES's built in tracking. It doesn't use the list management, or campaign management.
Installation
Install the package
composer require opetech/laravelses
Add Laravel SES as a mailer
Add to config/mail.php under mailers, to make sure the LaravelSes transport is available.
'laravel-ses' => [ 'transport' => 'laravel-ses', ]
Migrations
Run the migrations for the packages.
php artisan migrate
Publish the config
php artisan vendor:publish --provider="OpeTech\LaravelSes\LaravelSesServiceProvider
Setup SES and SNS
For this you'll need IAM credentials that have full access to SNS and SES. Add these crendentials as you would for using SES without the package. i.e. config/mail.php
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
Before running the below command, make sure your app's endpoints are publically available. SNS will hit your endpoints to confirm the subscriptions. If you're testing or playing around in development, we recommended you use a service like Ngrok to temporarily allow the public internet to interact with your app.
Your APP_URL needs to be set correctly.
Run laravel-ses:setup-config-and-sns
- You will be prompted for a custom redirect domain. This is optional, but recommended for serious users. See Configuring the redirect domain for more info.
This will create a configuration set called "laravel-ses-{env}-configuration-set". You can customise the prefix by changing the config option "prefix".
It will also create an event destination (laravel-ses-{env}-event-destination) and an SNS topic (laravel-ses-{env}-topic). Again the prefix is customisable by changing the prefix config option.
Configuring the redirect domain
OPTIONAL
This option isn't required, as AWS will use its own domain, however it is suggested, as email providers see links matching the sending domain in your email content as a positive. From a user's point of view they will see AWS urls instead of your own URLs, which may put them off clicking links in your email.
The tracking domain should ideally be a subdomain of the sending domain's domain. This is better for spam scores. For example: sending domain - myemails.com, tracking domain. ses.myemails.com. Or if you're using a subdomain to send emails e.g. emails.example.com, use ses.example.com for the tracking.
We would also suggest avoiding using tracking in the subdomain as plugins such as ad blockers, malware detection etc, don't look favourably on the wording and could block the email, or break the content.
To configure a custom tracking domain follow these steps - https://docs.aws.amazon.com/ses/latest/dg/configure-custom-open-click-domains.html#configure-custom-open-click-domain.
We would also recommend setting up a custom "MAIL FROM" domain, otherwise messages sent through Amazon SES will be marked as originating from a subdomain of amazon.com. Instead of your own domain. This allows you to comply with DMARC policies and improves trust.
Batching
For the purpose of grouping stats, you can use "batching". Implement the OpeTech\LaravelSes\Contracts\Batchable contract, use the OpeTech\LaravelSes\Mailables\Batching trait and implement the getBatch method.
getBatch should return a string representing your batch.
LaravelSes will create a new batch if the batch doesn't exist at the time of sending.
batches are held in the laravel_ses_batches table.
Batching via Mailables
You can use batching directly on your Mailables:
<?php use OpeTech\LaravelSes\Contracts\Batchable; use OpeTech\LaravelSes\Mailables\Batching; class MyMailable extends Mailable implements Batchable { public function getBatch() :string { return 'my-first-batch'; } }
Batching via the Mail Facade
You can call the withBatch method, and provide the name for your batch.
Warning: This won't work if you're sending a queued mailable. Use Batching via Mailables instead. This is mainly used if you're not using mailables e.g. using the raw method.
use Illuminate\Mail\Message; use Illuminate\Support\Facades\Mail; Mail::withBatch('exports') ->raw('Your export is attached', function (Message $message) { return $message ->attach('yourexport.csv') ->to('hello@example.com') ->subject('My Subject') ->from('sender@example.com'); });
Batching Mail Notifications
You can add batching to your notiflacations using the mail channel. Instead of using MailMessage you need to use OpeTech\LaravelSes\Notifications\MailMessageWithBatching
public function toMail(object $notifiable) { return (new MailMessageWithBatching) ->from('hello@example.com') ->batch('restock_alerts') ->subject('The item you were watching has been restocked') ->line('Asics Superblasts have been restocked in your size') ->action('View Product', url('path/to/product')); }
ope-tech/laravel-ses 适用场景与选型建议
ope-tech/laravel-ses 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 124 次下载、GitHub Stars 达 44, 最近一次更新时间为 2024 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「aws」 「laravel」 「ses」 「clicks」 「tracking」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ope-tech/laravel-ses 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ope-tech/laravel-ses 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ope-tech/laravel-ses 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
Elastic Driver for Laravel Scout
simple api library.
A replica of the AWS Elastic Beanstalk worker SQS daemon (sqsd) in PHP
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
统计信息
- 总下载量: 124
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-17