ahmedghanem00 / tempmail-api-client
An API client for Temp-Mail service ( https://rapidapi.com/Privatix/api/temp-mail )
1.0.7
2024-05-18 07:51 UTC
Requires
- php: ^8.2
- doctrine/collections: ^2.0
- phlak/strgen: dev-master
- symfony/http-client: ^6.0 || ^7.0
- voku/arrayy: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.54
- phpstan/phpstan: 1.10.x-dev
- phpunit/phpunit: dev-main
This package is auto-updated.
Last update: 2024-12-15 15:17:31 UTC
README
An API client for Temp-Mail service ( https://rapidapi.com/Privatix/api/temp-mail )
Installation
composer require ahmedghanem00/tempmail-api-client
Usage
Client Initialization :
use ahmedghanem00\TempMailClient\Client; $client = new Client('YOUR_API_TOKEN');
Get Available Domains
Retrieve a fresh data from the server:
$client->retrieveMailDomains();
Get the cached domains in the client (Domains are cached when client initialized for the first time)
$client->getCachedMailDomains();
Generate a Random Email
$receiver = $client->generateFullyRandomReceiver(); ## OR $receiver = $client->generateRandomReceiverFromEmailName("my-random-email"); echo $receiver->getFullEmailAddress(); // string "bdmhnjbtyj@nuclene.com" OR "my-random-email@nuclene.com" echo $receiver->getEmailName(); // string "bdmhnjbtyj" OR "my-random-email" echo $receiver->getEmailDomain(); // string "nuclene.com"
Get email messages
$messages = $receiver->inbox()->retrieveAll(); /* @var $message \ahmedghanem00\TempMailClient\Model\Message */ foreach ($messages as $message) { echo $message->getSubject(); // string echo $message->getText(); // string echo $message->getSenderName(); // string "Joe" echo $message->getSenderEmail(); // string echo $message->getReceiveTimestamp(); // float echo $message->getHtml(); // string echo $message->getPreview(); // string # Message id echo $message->getServiceInternalId(); // string /* @var $attachment \ahmedghanem00\TempMailClient\Model\Attachment */ foreach ($message->getAttachments() as $attachment) { echo $attachment->getName(); // string echo $attachment->getContentType(); // string echo $attachment->getSize(); // int echo $attachment->getContent(); // string } }
Retrieve a Specific Message
$message = $receiver->inbox()->retrieveMessage(MessageId: "dk4kdkmv");
Delete a Specific Message
$receiver->inbox()->deleteMessage(MessageId: "dk4kdkmv");
LICENSE
Package is licensed under the MIT License. For more info, You can take a look at the License File