truehero/getnada-api

There is no license information available for the latest version (1.0) of this package.

PHP library for work with getnada.com private API

1.0 2019-02-14 11:24 UTC

This package is auto-updated.

Last update: 2025-06-15 01:58:01 UTC


README

Simple library for reading emails from inbox getnada.com

Install

For install use composer, and call in the command line: composer require truehero/getnada-api

Basic usage of the lib

<?php 
require __DIR__ . '/vendor/autoload.php';

use Truehero\Getnada;

$getnada = new Getnada();

OR with custom configured client

$api_version = 1;
$client = new \Truehero\CommonClient($api_version);
//$client->setUserAgent('Custom UA');
//$client->setHeaders(['Custom-Header' => 'Custom Header Value']);
//$client->setProxy('121.100.26.6');

$getnada = new Getnada($client);

Get list of available domains

$domains = $getnada->domains();

foreach ($domains as $domain) {
    echo 'Name: ' . $domain->getName();
    echo 'ID: ' . $domain->getId();
}

Get list of messages by inbox name

$email = 'hardcodedemail@getnada.com';
$box = $getnada->inbox($email);

foreach($box as $message) {
    echo 'ID: ' . $message->getId();
    echo 'From: ' . $message->getFrom();
    echo 'To: ' . $message->getTo();
    echo 'Date: ' . $message->getDate()->format('d-m-Y H:i:s');
    // echo $message->getDate()->getDate(); - date with default format
    echo 'Message: ' . $message->getMessage();
}

Get attaches of message

// directory, where we want to save attaches
$saveDir = __DIR__ . '/storage';

foreach($box as $message) {
   echo 'ID: ' . $message->getId();
   // ...
   echo 'Message: ' . $message->getMessage();

   // Check, if message has attaches
   if($message->hasAttaches()) {
       foreach($message->getAttaches() as $attach) {
           $file = $getnada->downloadFile($message, $attach, $saveDir);

           echo 'File was saved by path: ' . $file;
           
           echo 'Name: ' . $attach->getName();
           echo 'ID: ' . $attach->getId();
           echo 'Type: ' . $attach->getType();
           echo 'Size: ' . $attach->getSize()->format();
           echo 'Total Attaches: ' . $message->countAttaches();
       }
   }
}

Helper for generate a random email name

$email = $getnada->randomEmail($getnada->domains());
$box = $getnada->inbox($email);
// ...

Get info about new unread messages

if($getnada->hasNew($email)) {
    // mailbox has new unread messages   
}