Documentation ¶
Index ¶
- func CreateTextPlainBody() *models.BodyStructure
- func FetchEntityPartReader(e *message.Entity, index []int) (io.Reader, error)
- func IsMultipartError(err error) bool
- func MessageHeaders(raw RawMessage) (*models.MessageInfo, error)
- func MessageInfo(raw RawMessage) (*models.MessageInfo, error)
- func NewCRLFReader(r io.Reader) io.Reader
- func ParseEntityStructure(e *message.Entity) (*models.BodyStructure, error)
- func ReadMessage(r io.Reader) (*message.Entity, error)
- type MultipartError
- type RawMessage
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 IsMultipartError ¶
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 ¶
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 ¶
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