temp-mail-io/temp-mail-php
Composer 安装命令:
composer require temp-mail-io/temp-mail-php
包简介
关键字:
README 文档
README
The official PHP Client for Temp Mail. This library provides developers a straightforward way to create and manage temporary email addresses, retrieve and delete messages, all via the Temp Mail API.
Table of Contents
Features
- Create temporary email addresses with optional domain specifications
- Get current rate limits after API request
- Delete a temporary email along with all its messages
- Retrieve all messages for a specified email
- Get a specific message or download its attachment
Installation
To install this PHP package, run:
composer require temp-mail-io/temp-mail-php
Quick Start
Below is a simple example to get started:
<?php $emailClient = \TempMailIo\TempMailPhp\Factory::createEmailClient('YOUR_API_KEY'); $createResponse = $emailClient->create(); if ($createResponse->errorResponse !== null) { echo "Code: " . $response->errorResponse->error->code . PHP_EOL; echo "Detail: " . $response->errorResponse->error->detail . PHP_EOL; echo "Type: " . $response->errorResponse->error->type . PHP_EOL; exit; } // Use the created temporary email on the website, service, etc... $messagesResponse = $emailClient->getMessages($createResponse->successResponse->email); if ($messagesResponse->errorResponse !== null) { echo "Code: " . $messagesResponse->errorResponse->error->code . PHP_EOL; echo "Detail: " . $messagesResponse->errorResponse->error->detail . PHP_EOL; echo "Type: " . $messagesResponse->errorResponse->error->type . PHP_EOL; exit; } foreach ($messagesResponse->successResponse->messages as $message) { // Iterate over messages }
Usage Examples
Listing Domains
$response = \TempMailIo\TempMailPhp\Factory::createDomainClient('YOUR_API_KEY')->getAvailableDomains(); if ($response->errorResponse !== null) { // handle error } foreach ($response->successResponse->domains as $domain) { // Iterate over domains }
Getting Rate Limits
$response = \TempMailIo\TempMailPhp\Factory::createRateLimitClient('YOUR_API_KEY')->getStatus(); if ($response->errorResponse !== null) { // handle error } echo "Rate limit: " . $response->successResponse->limit . PHP_EOL; echo "Remaining limit: " . $response->successResponse->remaining . PHP_EOL; echo "Used limit: " . $response->successResponse->used . PHP_EOL; echo "Reset limit: " . $response->successResponse->reset . PHP_EOL;
You can also get rate limits from each success response:
$response = \TempMailIo\TempMailPhp\Factory::createEmailClient('YOUR_API_KEY')->create(); if ($response->errorResponse !== null) { // handle error } echo "Rate limit: " . $response->successResponse->rateLimit->limit . PHP_EOL; echo "Remaining limit: " . $response->successResponse->rateLimit->remaining . PHP_EOL; echo "Used limit: " . $response->successResponse->rateLimit->used . PHP_EOL; echo "Reset limit: " . $response->successResponse->rateLimit->reset . PHP_EOL;
Creating Temporary Email
$response = \TempMailIo\TempMailPhp\Factory::createEmailClient('YOUR_API_KEY')->create(); if ($response->errorResponse !== null) { // handle error } echo "Email: " . $response->successResponse->email . PHP_EOL;
Fetching and Deleting Messages
$emailClient = \TempMailIo\TempMailPhp\Factory::createEmailClient('YOUR_API_KEY'); $response = $emailClient->getMessages('your_email@example.com'); if ($response->errorResponse !== null) { // handle error } foreach ($response->successResponse->messages as $message) { // Iterate over messages } $messageClient = \TempMailIo\TempMailPhp\Factory::createMessageClient('YOUR_API_KEY'); $deleteResponse = $messageClient->delete($response->successResponse->messages[0]->id); if ($deleteResponse->errorResponse !== null) { // handle error }
Testing
We use the PHPUnit testing framework.
Run tests locally:
./vendor/bin/phpunit ./tests
In the CI, the tests and linters are automatically executed via GitHub Actions.
Contributing
We welcome and appreciate contributions! Please see our CONTRIBUTING.md for guidelines on how to open issues, submit pull requests, and follow our coding standards.
License
This project is licensed under the MIT License.
Support
If you encounter any issues, please open an issue on GitHub. We are happy to help you!
temp-mail-io/temp-mail-php 适用场景与选型建议
temp-mail-io/temp-mail-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 6, 最近一次更新时间为 2025 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「temp-mail」 「temp-email」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 temp-mail-io/temp-mail-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 temp-mail-io/temp-mail-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 temp-mail-io/temp-mail-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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.
Laravel contact us form package to send email and save to database
PHP client for temp-mail.ru.
A plugin for saving emails to a list
Sendy API implementation for Laravel
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-13