mime

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package mime implements the MIME encoding used for messages in Mute.

Index

Constants

View Source
const MaxMsgSize = 10485760 // 10GB

MaxMsgSize is the maximums size a MIME encoded message can have.

Variables

This section is empty.

Functions

func EncodeChunks

func EncodeChunks(
	header Header,
	msg string,
	size uint64,
) (chunks []string, err error)

EncodeChunks splits a MIME encoded message msg into multiple chunks of given size many bytes.

func New

func New(
	w io.Writer,
	header Header,
	msg string,
	attachments []*Attachment,
) error

New writes a MIME encoded message to w.

func Parse

func Parse(r io.Reader) (
	header *Header,
	subject string,
	message string,
	attachments []*Attachment,
	err error,
)

Parse parses a MIME encoded message.

func SplitMessage

func SplitMessage(msg string) (subject, message string)

SplitMessage splits a given Mute message msg into subject line (before the first newline) and actual message (after the first newline).

Types

type Attachment

type Attachment struct {
	Filename    string    // original filename of attachment
	Reader      io.Reader // the io.Reader to read the attachment from
	ContentType string    // e.g., ""application/pdf"
	Inline      bool      // attachment should be displayed inline
}

Attachment is a file attachment in Mute. The Content-Type of the MIME attachment is determined as follows:

  • if ContentType != "" ContentType is used
  • if ContentType == "" the Content-Type is derived from Filename
  • if no Content-Type could be derived "application/octet-stream" is used
type Header struct {
	From      string   // mandatory
	To        string   // mandatory
	Cc        []string // optional
	MessageID string   // mandatory
	InReplyTo string   // optional
}

Header is the header used for Mute message encodings.

func DecodeChunk

func DecodeChunk(chunk string) (
	header *Header,
	part string,
	piece, count uint64,
	err error,
)

DecodeChunk decodes the given chunk.

Jump to

Keyboard shortcuts

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