An API client for Temp-Mail service ( https://rapidapi.com/Privatix/api/temp-mail )
composer require ahmedghanem00/tempmail-api-client
use ahmedghanem00\TempMailClient\Client;
$client = new Client('YOUR_API_TOKEN');
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();
$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"
$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
}
}
$message = $receiver->inbox()->retrieveMessage(MessageId: "dk4kdkmv");
$receiver->inbox()->deleteMessage(MessageId: "dk4kdkmv");
Package is licensed under the MIT License. For more info, You can take a look at the License File