Last active
November 10, 2020 18:07
-
-
Save lucasaba/4ad68ceda5a369dbdcaebd7196f6b74f to your computer and use it in GitHub Desktop.
Scaricamento PEC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
use PhpPec\PecMessage; | |
use PhpPec\PecServer; | |
use Fetch\Attachment; | |
*/ | |
$server = new PecServer('aruba.server.pec.it', 445); | |
$server->setAuthentication('nome-utente', 'password'); | |
/** | |
* Aggiorna la lista delle PEC scaricando quelle non ancora lette | |
*/ | |
foreach ($server->recuperaPecInIngresso('SUBJECT "POSTA CERTIFICATA: " UNSEEN') as $messaggio) { | |
/* @var PecMessage $messggio */ | |
echo $messaggio->getOggetto() . "\n"; | |
foreach ($messaggio->getAttachments() as $allegatoPec) { | |
/* @var Attachment $allegatoPec */ | |
echo $allegatoPec->getFileName() . "\n"; | |
// Per salvare l'allegato: file_put_contents($allegatoPec->getFileName(), $allegatoPec->getData()) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lucasaba, check also this fork https://gist.github.com/3v1n0/99de748e5c191e82423c69d21e793ba2
It does it using a python script that also extracts the PECs in a folder