rfc822

package
v0.0.0-...-0f7d4fc Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTextPlainBody

func CreateTextPlainBody() *models.BodyStructure

CreateTextPlainBody creats a plain-vanilla text/plain body structure.

func FetchEntityPartReader

func FetchEntityPartReader(e *message.Entity, index []int) (io.Reader, error)

func IsMultipartError

func IsMultipartError(err error) bool

IsMultipartError returns a boolean indicating whether the error is known to report that the multipart message is malformed and could not be parsed.

func MessageHeaders

func MessageHeaders(raw RawMessage) (*models.MessageInfo, error)

MessageHeaders populates a models.MessageInfo struct for the message. based on the reader returned by NewReader. Minimal information is included. There is no body structure or RFC822Headers set

func MessageInfo

func MessageInfo(raw RawMessage) (*models.MessageInfo, error)

MessageInfo populates a models.MessageInfo struct for the message. based on the reader returned by NewReader

func NewCRLFReader

func NewCRLFReader(r io.Reader) io.Reader

NewCRLFReader returns a reader with CRLF line endings

func ParseEntityStructure

func ParseEntityStructure(e *message.Entity) (*models.BodyStructure, error)

ParseEntityStructure will parse the message and create a multipart structure for multipart messages. Parsing is done on a best-efforts basis:

If the content-type cannot be parsed, ParseEntityStructure will try to fix it; otherwise, it returns a text/plain mime type as a fallback. No error will be returned.

If a charset or encoding error is encountered for a message part of a multipart message, the error is logged and ignored. In those cases, we still get a valid message body but the content is just not decoded or converted. No error will be returned.

If reading a multipart message fails, ParseEntityStructure will return a multipart error. This error indicates that this message is malformed and there is nothing more we can do. The caller is then advised to use a single text/plain body structure using CreateTextPlainPart().

func ReadMessage

func ReadMessage(r io.Reader) (*message.Entity, error)

ReadMessage is a wrapper for the message.Read function to read a message from r. The message's encoding and charset are automatically decoded to UTF-8. If an unknown charset or unknown encoding is encountered, the error is logged but a nil error is returned since the entity object can still be read.

Types

type MultipartError

type MultipartError struct {
	// contains filtered or unexported fields
}

func (MultipartError) Error

func (u MultipartError) Error() string

func (MultipartError) Unwrap

func (u MultipartError) Unwrap() error

type RawMessage

type RawMessage interface {
	NewReader() (io.ReadCloser, error)
	ModelFlags() (models.Flags, error)
	Labels() ([]string, error)
	UID() models.UID
}

RawMessage is an interface that describes a raw message

Jump to

Keyboard shortcuts

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