PHP code example of ahmedghanem00 / tempmail-api-client

1. Go to this page and download the library: Download ahmedghanem00/tempmail-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ahmedghanem00 / tempmail-api-client example snippets


use ahmedghanem00\TempMailClient\Client;

$client = new Client('YOUR_API_TOKEN');

$client->retrieveMailDomains();

$client->getCachedMailDomains();

$receiver = $client->generateFullyRandomReceiver();
## OR
$receiver = $client->generateRandomReceiverFromEmailName("my-random-email");

echo $receiver->getFullEmailAddress(); // string "[email protected]" OR "[email protected]"
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");