Skip to content

Instantly share code, notes, and snippets.

@lucasaba
Last active November 10, 2020 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasaba/4ad68ceda5a369dbdcaebd7196f6b74f to your computer and use it in GitHub Desktop.
Save lucasaba/4ad68ceda5a369dbdcaebd7196f6b74f to your computer and use it in GitHub Desktop.
Scaricamento PEC
<?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())
}
}
@3v1n0
Copy link

3v1n0 commented Nov 10, 2020

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment