lucasaba / php-pec

A php library to manage certified electronic mail (RFC 6109 - PEC)
6 stars 6 forks source link

Fatal error: Declaration of PhpPec\PecMessage::getTestiOriginali() must be compatible with PhpPec\PecMessageInterface::getTestiOriginali($inHtml = false) in C:\Program Files\NetMake\v9-php81\wwwroot\PEC\PhpPec\PecMessage.php on line 152 #8

Open SandroL-als opened 2 months ago

SandroL-als commented 2 months ago

Ciao, ho provato a far funzionare la classe ma ricevo l'errore nel titolo, sicuramente sbaglio qualcosa, non ho mai usato Fetch, sino ad ora per "leggere" la posta ho usato IMAP ma per la PEC non sono riuscito a scaricare gli allegati originali. il codice: `require_once("vendor/autoload.php"); use Fetch\Server; use Fetch\Message;

require_once("PhpPec/PecMessageInterface.php"); require_once("PhpPec/PecServer.php"); require_once("PhpPec/PecMessage.php");

use PhpPec\PecMessageInterface; use PhpPec\PecMessage; use PhpPec\PecServer;

//$server = new Server('imaps.pec.aruba.it', 993); $server = new PecServer('imaps.pec.aruba.it', 993); $server->setAuthentication('mgcarrentalsrl.multe@pec.it', 'password');

$messages = $server->getMessages();

foreach ($messages as $message) { echo "Subject: {$message->getSubject()}", PHP_EOL;

$allegati = $message->getAllegati();
foreach($allegati as $allegato) {
    echo "Nome file: ".$allegato->getFileName()."\n";
    echo "Dimensione: ".$allegato->getSize()."\n";
    echo "MIME: ".$allegato->getMimeType()."\n";
    file_put_contents($allegato->getFileName(), $allegato->getData());

}

} `

image

un'ultima domanda posso parzializzare la lettura usando UID? Grazie in anticipo.

lucasaba commented 2 months ago

Ciao e grazie mille per la segnalazione.

Purtroppo il progetto è un po vecchio e non lo seguo più molto. La mia ipotesi è che quando l'ho scritto ho utilizzato una versione di PHP meno...pignola. Effettivamente la firma dei metodi è differente. Probabilmente è sufficiente modificare https://github.com/lucasaba/php-pec/blob/master/src/PhpPec/PecMessage.php#L152 così:

function getTestiOriginali($inHtml = false)

Se fosse solo quello, potresti fare una PR su questo repository, così aggiorno il codice con la tua fix?

SandroL-als commented 2 months ago

Ciao Luca, dopo la modifica funziona!! Mi rimane un problema posso far partire la lettura da una determinata data con IMAP (imap_search($inbox, 'SINCE "'.date("d F Y'"); o da uno specifico UID? Grazie in anticipo Sandro.