mindtwo/px-mail-laravel-driver
Composer 安装命令:
composer require mindtwo/px-mail-laravel-driver
包简介
A project to integrate TX Mail as mail service in Laravel.
关键字:
README 文档
README
A Laravel mail driver for the PX Mail (TX Mail) API.
Installation
composer require mindtwo/px-mail-laravel-driver
Configuration
Publish the config file
php artisan vendor:publish --tag=px-mail
This publishes config/px-mail.php. This step is optional if you configure everything via environment variables.
Environment variables
Add the following to your .env file:
TX_MAIL_URL=https://tx-mail.api.pl-x.cloud TX_MAIL_TENANT=your-tenant TX_MAIL_CLIENT_ID=your-client-id TX_MAIL_CLIENT_SECRET=your-client-secret
Register the mailer
Add the transport to the mailers section in config/mail.php:
'mailers' => [ 'txmail' => [ 'transport' => 'txmail', ], ],
Then set it as your default mailer in .env:
MAIL_MAILER=txmail
Config reference
| Key | Env variable | Default | Description |
|---|---|---|---|
stage |
APP_ENV |
APP_ENV |
The application stage. local is mapped to preprod automatically. |
mailer_url |
TX_MAIL_URL |
— | Base URL of the TX Mail API. |
mailer_api_version |
TX_MAIL_API_VERSION |
v1 |
API version appended to the base URL. |
tenant |
TX_MAIL_TENANT |
— | Your TX Mail tenant identifier used in the API path. |
client_id |
TX_MAIL_CLIENT_ID |
— | Client ID for M2M authentication. |
client_secret |
TX_MAIL_CLIENT_SECRET |
— | Client secret for M2M authentication. |
debug |
TX_MAIL_DEBUG |
false |
When true, enables HTTP-level request/response logging for all API calls. |
log_send |
TX_MAIL_LOG_SEND |
false |
When true, logs each outgoing send attempt (sender, recipient, tenant, URL). Can be enabled independently of debug. |
headers |
— | [] |
Additional headers merged into every request. See Additional headers. |
Usage
Once configured, use Laravel's Mail facade as normal:
Mail::to($user)->send(new OrderConfirmation($order));
Context headers
The driver supports optional x-context-tenant-code and x-context-domain-code headers. These are useful in multi-tenant applications where the sending context needs to be forwarded to the mail API.
Set them on the ApiClient via the service container's resolving callback, typically inside a service provider:
use mindtwo\LaravelPxMail\Client\ApiClient; $this->app->resolving(ApiClient::class, function (ApiClient $client) { $client->setContextTenant(tenant()->code); $client->setContextDomain(domain()->code); });
The callbacks are resolved fresh on every ApiClient instantiation, so the values are always up to date.
You can also set them directly on the resolved instance at any point before sending:
app(ApiClient::class) ->setContextTenant('acme') ->setContextDomain('shop');
Additional headers
Static additional headers can be defined in the config:
// config/px-mail.php 'headers' => [ 'X-Custom-Header' => 'value', ],
They can also be set at runtime, for example in middleware:
config(['px-mail.headers' => ['X-Custom-Header' => 'value']]);
Logging
Send logging
Enable send logging to record every outgoing mail attempt:
TX_MAIL_LOG_SEND=true
Logs the tenant, client ID, API URL, sender address, and anonymized recipient (e.g. j***@example.com) before each send. All entries are prefixed with [px-mail].
Debug mode
Enable debug mode for HTTP-level logging:
TX_MAIL_DEBUG=true
Logs the full request and response details for every API call. Errors (4xx/5xx) are always logged regardless of this setting.
Both options can be combined or used independently.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@mindtwo.de instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
mindtwo/px-mail-laravel-driver 适用场景与选型建议
mindtwo/px-mail-laravel-driver 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mindtwo/px-mail-laravel-driver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mindtwo/px-mail-laravel-driver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mindtwo/px-mail-laravel-driver 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Alfabank REST API integration
High-performance, opinionated PHP 8 web framework with O(1) routing, parallel async MySQL, type-safe asset bridge, and React-island frontend
Laravel package for Accurate Online API integration.
The skeleton application for the Geoffrey agent framework.
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-21