message

package
v0.0.0-...-491d012 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

utilities to work on raw message

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNonAsciiCharDetected when an email body does not contain only 7 bits ascii char
	ErrNonAsciiCharDetected = errors.New("email must contains only 7-bit ASCII characters")
)

Functions

func FoldHeader

func FoldHeader(header *[]byte)

FoldHeader retun header value according to RFC 2822 https://tools.ietf.org/html/rfc2822#section-2.1.1 There are two limits that this standard places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF. TODO: refactor Foldheader

func GetHostFromAddress

func GetHostFromAddress(address string) string

getHostFromAddress returns host part from an email address Warning this check assume to get a valid email address

func RawGetHeaders

func RawGetHeaders(raw *[]byte) []byte

RawGetHeaders return raw headers

func RawGetMessageId

func RawGetMessageId(raw *[]byte) []byte

RawGetMessageId return Message-ID or empty string if to found

func RawHaveHeader

func RawHaveHeader(raw *[]byte, header string) bool

RawHaveHeader check igf header header is present in raw mail

Types

type Envelope

type Envelope struct {
	MailFrom string
	RcptTo   []string
}

Envelope reprsente a message envelope

func (Envelope) String

func (e Envelope) String() string

type Message

type Message struct {
	mail.Message
}

message represents an email message

func New

func New(rawmail *[]byte) (m *Message, err error)

func (*Message) AddHeader

func (m *Message) AddHeader(key, value string)

addheader add an header

func (*Message) DelHeader

func (m *Message) DelHeader(key string)

delHeader deletes the values associated with key.

func (*Message) GetHeader

func (m *Message) GetHeader(key string) string

getHeader get one header, or the first occurence if there is multipke headers with this key

func (*Message) GetHeaders

func (m *Message) GetHeaders(key string) []string

getHeaders returns all the headers corresponding to the key key

func (*Message) GetRaw

func (m *Message) GetRaw() (rawMessage []byte, err error)

getRaw returns raw message some cleanup are made wrap headers line to 999 char max

func (*Message) HaveHeader

func (m *Message) HaveHeader(key string) bool

heaveHeader check the existence of header header

func (*Message) SetHeader

func (m *Message) SetHeader(key, value string)

Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key.

Jump to

Keyboard shortcuts

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