message

package
v0.0.0-...-7dc0240 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

utilities to work on raw message

Index

Constants

View Source
const (
	AuthDataStart = "[cocosmail_auth_data=start] "
	AuthDataEnd   = " [cocosmail_auth_data=end]"
)

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

func RedactHeaders

func RedactHeaders(email string) (emailRedacted string)

RedactHeaders removes sensitive information from the email headers once

func RedactHeadersRemove

func RedactHeadersRemove(email string) (emailRedacted string)

RedactHeadersRemove removes redaction marks from the email headers once.

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.

func (*Message) SetHeaders

func (m *Message) SetHeaders(key string, value []string)

SetHeaders sets the header entries associated with key to the multiple 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