-
-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Certified email (PEC) #512
Comments
Hi, I don't understand your question, can you be more specific on the issue? |
The certified emails pec in Italy have a different structure I guess and the body of the email is inside an attachment or something. |
Sure, I use this library with PEC providers too. For metadatas you need to inspect attachments like The real mail is another attachment that can be inspected as an |
Do you have a snippet of code, because for me it is not working |
I can only give you a part of the code since the rest is NDA protected. $mailbox = $connection->getMailbox('INBOX');
$messages = $mailbox->getMessages(new Since($dataMinima));
foreach ($messages as $message) {
foreach ($message->getAttachments() as $attachment) {
if ('daticert.xml' !== $attachment->getFilename()) {
continue;
}
$xml = $attachment->getDecodedContent();
$dom = new DOMDocument();
$dom->loadXML($xml);
$domXpath = new DOMXPath($dom);
$msgIdNodeList = $domXpath->query('/postacert/dati/msgid');
if (1 !== $msgIdNodeList->length) {
continue;
}
$msgId = $msgIdNodeList->item(0)->textContent;
$consegna = null !== ($t = $domXpath->query('/postacert/dati/consegna')->item(0)) ? \mb_strtolower($t->textContent) : null;
$tipo = $domXpath->query('/postacert')->item(0)->getAttribute('tipo');
$data = Date::createFromFormat('d/m/Y H:i:s O', \sprintf(
'%s %s %s',
$domXpath->query('/postacert/dati/data/giorno')->item(0)->textContent,
$domXpath->query('/postacert/dati/data/ora')->item(0)->textContent,
$domXpath->query('/postacert/dati/data')->item(0)->getAttribute('zona')
));
$data = $data->setTimezone(new DateTimeZone(\date_default_timezone_get()));
$identificativo = $domXpath->query('/postacert/dati/identificativo')->item(0)->textContent;
$errore = $domXpath->query('/postacert')->item(0)->getAttribute('errore');
$oggetto = null !== ($t = $domXpath->query('/postacert/intestazione/oggetto')->item(0)) ? $t->textContent : null;
$gestore = $domXpath->query('/postacert/dati/gestore-emittente')->item(0)->textContent;
$ricevuta = null !== ($t = $domXpath->query('/postacert/dati/ricevuta')->item(0)) ? $t->getAttribute('tipo') : null;
$erroreEsteso = null !== ($t = $domXpath->query('/postacert/dati/errore-esteso')->item(0)) ? $t->textContent : null; |
Hello
Is it possible to fetch the message of the email? At moment the body is not correct with email that are certified email
Thanks
The text was updated successfully, but these errors were encountered: