1. Go to this page and download the library: Download temp-mail-io/temp-mail-php 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/ */
temp-mail-io / temp-mail-php example snippets
$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
}
$response = \TempMailIo\TempMailPhp\Factory::createDomainClient('YOUR_API_KEY')->getAvailableDomains();
if ($response->errorResponse !== null) {
// handle error
}
foreach ($response->successResponse->domains as $domain) {
// Iterate over domains
}