message

package
v3.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package message contains set of tools to convert message between Proton API and IMAP format.

Index

Constants

View Source
const InternalIDDomain = `protonmail.internalid`

InternalIDDomain is used as a placeholder for reference/message ID headers to improve compatibility with various clients.

Variables

View Source
var (
	ErrDecryptionFailed = errors.New("message could not be decrypted")
	ErrNoSuchKeyRing    = errors.New("the keyring to decrypt this message could not be found")
)
View Source
var ErrInvalidAttachmentPacket = errors.New("invalid attachment packet")

Functions

func BuildRFC822Into added in v3.1.0

func BuildRFC822Into(kr *crypto.KeyRing, decrypted *DecryptedMessage, opts JobOptions, buf *bytes.Buffer) error

func DecryptAndBuildRFC822 added in v3.6.0

func DecryptAndBuildRFC822(kr *crypto.KeyRing, msg proton.Message, attData [][]byte, opts JobOptions) ([]byte, error)

func DecryptAndBuildRFC822Into added in v3.6.0

func DecryptAndBuildRFC822Into(kr *crypto.KeyRing, msg proton.Message, attData [][]byte, opts JobOptions, buf *bytes.Buffer) error

func HeaderLines

func HeaderLines(header []byte) [][]byte

HeaderLines returns each line in the given header.

func SanitizeMessageDate

func SanitizeMessageDate(msgTime int64) time.Time

SanitizeMessageDate will return time from msgTime timestamp. If timestamp is not after epoch the RFC822 publish day will be used. No message should realistically be older than RFC822 itself.

Types

type Attachment

type Attachment struct {
	Header      mail.Header
	Name        string
	ContentID   string
	MIMEType    string
	MIMEParams  map[string]string
	Disposition proton.Disposition
	Data        []byte
}

type Body

type Body string

type DecryptedAttachment added in v3.6.0

type DecryptedAttachment struct {
	Packet    []byte
	Encrypted []byte
	Data      bytes.Buffer
	Err       error
}

type DecryptedMessage added in v3.6.0

type DecryptedMessage struct {
	Msg         proton.Message
	Body        bytes.Buffer
	BodyErr     error
	Attachments []DecryptedAttachment
}

func DecryptMessage added in v3.6.0

func DecryptMessage(kr *crypto.KeyRing, msg proton.Message, attData [][]byte) DecryptedMessage

type JobOptions

type JobOptions struct {
	IgnoreDecryptionErrors bool // Whether to ignore decryption errors and create a "custom message" instead.
	SanitizeDate           bool // Whether to replace all dates before 1970 with RFC822's birthdate.
	AddInternalID          bool // Whether to include MessageID as X-Pm-Internal-Id.
	AddExternalID          bool // Whether to include ExternalID as X-Pm-External-Id.
	AddMessageDate         bool // Whether to include message time as X-Pm-Date.
	AddMessageIDReference  bool // Whether to include the MessageID in References.
	SanitizeMBOXHeaderLine bool // Whether to ignore header line representing MBOX delimiter
}

type MIMEBody

type MIMEBody string

type Message

type Message struct {
	MIMEBody    MIMEBody
	RichBody    Body
	PlainBody   Body
	Attachments []Attachment
	MIMEType    rfc822.MIMEType
	IsReply     bool

	Subject  string
	Sender   *mail.Address
	ToList   []*mail.Address
	CCList   []*mail.Address
	BCCList  []*mail.Address
	ReplyTos []*mail.Address

	References []string
	ExternalID string
	InReplyTo  string
	XForward   string
}

func Parse

func Parse(r io.Reader) (m Message, err error)

Parse parses an RFC822 message.

func ParseAndAllowInvalidAddressLists added in v3.2.0

func ParseAndAllowInvalidAddressLists(r io.Reader) (m Message, err error)

ParseAndAllowInvalidAddressLists parses an RFC822 message and allows email address lists to be invalid.

func ParseWithParser

func ParseWithParser(p *parser.Parser, allowInvalidAddressLists bool) (m Message, err error)

ParseWithParser parses an RFC822 message using an existing parser.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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