mirror of
https://github.com/axllent/mailpit.git
synced 2025-01-04 00:15:54 +02:00
65 lines
1.3 KiB
Go
65 lines
1.3 KiB
Go
package data
|
|
|
|
import (
|
|
"net/mail"
|
|
"time"
|
|
|
|
"github.com/jhillyerd/enmime"
|
|
)
|
|
|
|
// Message struct for loading messages. It does not include physical attachments.
|
|
type Message struct {
|
|
ID string
|
|
Read bool
|
|
From *mail.Address
|
|
To []*mail.Address
|
|
Cc []*mail.Address
|
|
Bcc []*mail.Address
|
|
Subject string
|
|
Date time.Time
|
|
Created time.Time
|
|
Text string
|
|
HTML string
|
|
Size int
|
|
Inline []Attachment
|
|
Attachments []Attachment
|
|
}
|
|
|
|
// Attachment struct for inline and attachments
|
|
type Attachment struct {
|
|
PartID string
|
|
FileName string
|
|
ContentType string
|
|
ContentID string
|
|
Size int
|
|
}
|
|
|
|
// Summary struct for frontend messages
|
|
type Summary struct {
|
|
ID string
|
|
Read bool
|
|
From *mail.Address
|
|
To []*mail.Address
|
|
Cc []*mail.Address
|
|
Bcc []*mail.Address
|
|
Subject string
|
|
Created time.Time
|
|
Size int
|
|
Attachments int
|
|
}
|
|
|
|
// AttachmentSummary returns a summary of the attachment without any binary data
|
|
func AttachmentSummary(a *enmime.Part) Attachment {
|
|
o := Attachment{}
|
|
o.PartID = a.PartID
|
|
o.FileName = a.FileName
|
|
if o.FileName == "" {
|
|
o.FileName = a.ContentID
|
|
}
|
|
o.ContentType = a.ContentType
|
|
o.ContentID = a.ContentID
|
|
o.Size = len(a.Content)
|
|
|
|
return o
|
|
}
|