pec

package
v0.0.0-...-410dbe8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePec

func ParsePec(msg *mail.Message) (*PECMail, *DatiCert, error)

Function to parse the PEC email Extracts the envelope and the daticert.xml

func ReadEmail

func ReadEmail(filePath string) []byte

ReadEmail reads and parses an .eml file, extracting headers, body, and attachments

func Verify

func Verify(filename string) error

func VerifySMIMEWithOpenSSL

func VerifySMIMEWithOpenSSL(emlFile string) error

Function to verify the S/MIME signature using OpenSSL TBD: Remove dependency on external program

Types

type DatiCert

type DatiCert struct {
	XMLName      xml.Name `xml:"postacert"`
	Tipo         string   `xml:"tipo,attr"`
	Errore       string   `xml:"errore,attr"`
	Intestazione struct {
		Mittente    string `xml:"mittente"`
		Destinatari struct {
			Tipo string `xml:"tipo,attr"`
			Val  string `xml:",chardata"`
		} `xml:"destinatari"`
		Risposte string `xml:"risposte"`
		Oggetto  string `xml:"oggetto"`
	} `xml:"intestazione"`
	Dati struct {
		GestoreEmittente string `xml:"gestore-emittente"`
		Data             struct {
			Zona   string `xml:"zona,attr"`
			Giorno string `xml:"giorno"`
			Ora    string `xml:"ora"`
		} `xml:"data"`
		Identificativo string `xml:"identificativo"`
		MsgID          string `xml:"msgid"`
		ErroreEsteso   string `xml:"errore-esteso,omitempty"`
	} `xml:"dati"`
}

Define the structure of the DatiCert XML

type Envelope

type Envelope struct {
	From    string `json:"from"`
	To      string `json:"to"`
	Subject string `json:"subject"`
	Date    string `json:"date"`
}

type PECMail

type PECMail struct {
	Envelope  Envelope `json:"envelope"`
	MessageID string   `json:"message_id"`
	PecType   PecType  `json:"pec_type"`
}

type PecType

type PecType int
const (
	None PecType = iota
	CertifiedEmail
	DeliveryReceipt
	DeliveryErrorReceipt
	AcceptanceReceipt
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL