ahmedghanem00/tempmail-api-client

An API client for Temp-Mail service ( https://rapidapi.com/Privatix/api/temp-mail )

1.0.0 2024-04-01 00:43 UTC

This package is auto-updated.

Last update: 2024-05-01 17:06:24 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