gmime

package
v0.0.0-...-61cd6b7 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package gmime implements the MIME, port of C GMime

Index

Examples

Constants

View Source
const (
	GMIME_FILTER_BEST_CHARSET  = (1 << 0)
	GMIME_FILTER_BEST_ENCODING = (1 << 1)
)

type GMimeFilterBestFlags int

View Source
const (
	GMIME_ENCODING_CONSTRAINT_7BIT   = C.GMIME_ENCODING_CONSTRAINT_7BIT
	GMIME_ENCODING_CONSTRAINT_8BIT   = C.GMIME_ENCODING_CONSTRAINT_8BIT
	GMIME_ENCODING_CONSTRAINT_BINARY = C.GMIME_ENCODING_CONSTRAINT_BINARY
)

type GMimeEncodingConstraint int

View Source
const (
	GMIME_FILTER_FROM_MODE_DEFAULT = 0
	GMIME_FILTER_FROM_MODE_ESCAPE  = 0
	GMIME_FILTER_FROM_MODE_ARMOR   = 0
)
View Source
const (
	GMIME_FILTER_GZIP_MODE_ZIP   = C.GMIME_FILTER_GZIP_MODE_ZIP
	GMIME_FILTER_GZIP_MODE_UNZIP = C.GMIME_FILTER_GZIP_MODE_UNZIP
)
View Source
const (
	GMIME_FILTER_HTML_PRE               uint32 = (1 << 0)
	GMIME_FILTER_HTML_CONVERT_NL               = (1 << 1)
	GMIME_FILTER_HTML_CONVERT_SPACES           = (1 << 2)
	GMIME_FILTER_HTML_CONVERT_URLS             = (1 << 3)
	GMIME_FILTER_HTML_MARK_CITATION            = (1 << 4)
	GMIME_FILTER_HTML_CONVERT_ADDRESSES        = (1 << 5)
	GMIME_FILTER_HTML_ESCAPE_8BIT              = (1 << 6)
	GMIME_FILTER_HTML_CITE                     = (1 << 7)
)
View Source
const (
	GMIME_FILTER_ENRICHED_IS_RICHTEXT int32 = (1 << 0)
)

Variables

This section is empty.

Functions

func AssignJanitor

func AssignJanitor(self Janitor)

func CastBufferedStream

func CastBufferedStream(cs *C.GMimeStream) *aBufferedStream

func CastContentDisposition

func CastContentDisposition(c *C.GMimeContentDisposition) *aContentDisposition

func CastDataWrapper

func CastDataWrapper(dw *C.GMimeDataWrapper) *aDataWrapper

func CastFileStream

func CastFileStream(cfs *C.GMimeStreamFile) *aFileStream

func CastMemStream

func CastMemStream(cms *C.GMimeStreamMem) *aMemStream

func CastMessage

func CastMessage(m *C.GMimeMessage) *aMessage

func CastNullStream

func CastNullStream(cms *C.GMimeStreamNull) *aNullStream

func CastObject

func CastObject(o *C.GMimeObject) *anObject

func CastPart

func CastPart(p *C.GMimePart) *aPart

func CastStream

func CastStream(cs *C.GMimeStream) *aStream

func MewFromFilter

func MewFromFilter(flags int) *aFilter

func NewBasicFilter

func NewBasicFilter(encoding string, encode bool) *aFilter

func NewBestFilter

func NewBestFilter(flags int) *aBestFilter

func NewCRLFFilter

func NewCRLFFilter(encode bool, dots bool) *aFilter

func NewCharsetFilter

func NewCharsetFilter(source string, target string) *aFilter

func NewContentDispositionFromString

func NewContentDispositionFromString(str string) *aContentDisposition

func NewEnrichedFilter

func NewEnrichedFilter(flags int32) *aFilter

func NewGZipFilter

func NewGZipFilter(mode int, level int) *aFilter

func NewHTMLFilter

func NewHTMLFilter(flags uint32, colour int32) *aFilter

func NewMD5Filter

func NewMD5Filter() *aFilterMD5

func NewStripFilter

func NewStripFilter() *aFilter

func NewYEncFilter

func NewYEncFilter(encode bool) *aFilter

func Shutdown

func Shutdown()

This function really need only for valgrind

Types

type Address

type Address interface {
	Janitor
	Name() string
	SetName(string)
}

XXX The underlying type-unsafe C implementation is modeled here with a type-safe Object-Oriented design, which is a modified form of the Composite Design Pattern. Specifically, Address is the Component, Mailbox is the Leaf, and Group & AddressList co-operate to act as the Composite. SEE TestCompositeAddress.

func CastAddress

func CastAddress(ca *C.InternetAddress) Address

type AddressList

type AddressList interface {
	Janitor
	GetLength() int
	Clear()
	Add(Address) int
	Prepend(AddressList)
	Append(AddressList)
	Insert(Address, int)
	Remove(Address) bool
	RemoveAt(int) bool
	Contains(Address) bool
	IndexOf(Address) int
	GetAddress(int) Address
	SetAddress(Address, int)
	ToString(bool) string
	Walk(callback func(Address))
	Slice() []Address
}

func ParseString

func ParseString(str string) AddressList

type BufferedStream

type BufferedStream interface {
	Stream
	Gets(char *[]byte, max int64) int64
	ReadLn(buffer *[]byte)
}

func NewBufferedStream

func NewBufferedStream(source Stream, mode C.GMimeStreamBufferMode) BufferedStream

type Compose

type Compose interface {
	AddTo(string, string)
	AddCC(string, string)
	AddBCC(string, string)
	AddSubject(string)
	AddFrom(string)
	AddText(string, string)
	AddHTML(string, string)
	AddTextReader(io.Reader)
	AddHTMLReader(io.Reader)

	To() string
	Subject() (string, bool)
	Text() string
	HTML() string
	From() (string, bool)
	Recipient() string
	ToString() string
}

func NewCompose

func NewCompose() Compose
Example

Simple message from sender@example.com to awesome@example.com

composer := NewCompose()
composer.AddFrom("Good Sender <good_sender@example.com>")
composer.AddTo("good_customer@example.com", "Good Customer")

// read data from a file:
fileHandler, _ := os.Open("composer_test.go")
defer fileHandler.Close()
reader := bufio.NewReader(fileHandler)

composer.AddHTMLReader(reader)
Output:

type ContentDisposition

type ContentDisposition interface {
	Janitor
	Parametrized
	Disposition() string
	ToString(fold bool) string
	IsAttachment() bool
}

type ContentEncodingState

type ContentEncodingState interface {
	Outlen(inlen int) (outlen int)
	Step(in []byte) (out []byte)
	Flush(in []byte) (out []byte)
}

func NewContentDecoder

func NewContentDecoder(encoding string) ContentEncodingState

func NewContentEncoder

func NewContentEncoder(encoding string) ContentEncodingState

type ContentType

type ContentType interface {
	Janitor
	Parametrized
	ToString() string
	MediaType() string
	MediaSubtype() string
}

func CastContentType

func CastContentType(ct *C.GMimeContentType) ContentType

func NewContentType

func NewContentType(ctype string, csubtype string) ContentType

func NewContentTypeFromString

func NewContentTypeFromString(str string) ContentType

type DataWrapper

type DataWrapper interface {
	Janitor
	Encoding() string
	WriteToStream(stream Stream) uintptr
	Stream() Stream
}

func NewDataWrapper

func NewDataWrapper() DataWrapper

func NewDataWrapperWithStream

func NewDataWrapperWithStream(stream Stream, encoding string) DataWrapper

type FileStream

type FileStream interface {
	Stream
	Owner() bool
	SetOwner(bool)
}

func NewFileStream

func NewFileStream(f *C.FILE) FileStream

func NewFileStreamForPath

func NewFileStreamForPath(name string, mode string) FileStream

func NewFileStreamWithBounds

func NewFileStreamWithBounds(f *C.FILE, start int64, end int64) FileStream

func NewFileStreamWithMode

func NewFileStreamWithMode(f *C.FILE, mode string) FileStream

type Filter

type Filter interface {
	Copy() Filter
	Reset()
}

type FilterBest

type FilterBest interface {
	Charset() string
	Encoding() string
}

type FilterFullLowlevelInterface

type FilterFullLowlevelInterface interface {
	Filter(inbuf []byte, prespace int) (outbuf []byte, outlen int, outprespace int)
	Complete(inbuf []byte, prespace int) (outbuf []byte, outlen int, outprespace int)
}

FIXME: Merge with Filter when we implement this

type FsStream

type FsStream interface {
	Stream
	Owner() bool
	SetOwner(bool)
}

func NewFsStream

func NewFsStream(fd int) FsStream

func NewFsStreamForPath

func NewFsStreamForPath(name string, flags int, mode int) FsStream

func NewFsStreamWithBounds

func NewFsStreamWithBounds(fd int, start int64, end int64) FsStream

type GMimeParamsCallback

type GMimeParamsCallback func(name string, value string)

type Group

type Group interface {
	Address
	Members() AddressList
	SetMembers(AddressList)
	AddMember(Address) int
}

type GroupAddress

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

func CastGroupAddress

func CastGroupAddress(ga *C.InternetAddressGroup) *GroupAddress

func NewGroupAddress

func NewGroupAddress(name string) *GroupAddress

func (*GroupAddress) AddMember

func (group *GroupAddress) AddMember(newAddress Address) int

func (*GroupAddress) Members

func (group *GroupAddress) Members() AddressList

func (GroupAddress) Name

func (a GroupAddress) Name() string

func (*GroupAddress) SetMembers

func (group *GroupAddress) SetMembers(list AddressList)

func (GroupAddress) SetName

func (a GroupAddress) SetName(name string)

type HeaderIterator

type HeaderIterator interface {
	Janitor
	Name() string
	Value() string
	Next() bool
}

Very minimal interface, to inspection only

type InternetAddressList

type InternetAddressList struct {
	*PointerMixin
}

func CastInternetAddressList

func CastInternetAddressList(cList *C.InternetAddressList) *InternetAddressList

func NewAddressList

func NewAddressList() *InternetAddressList

func (*InternetAddressList) Add

func (l *InternetAddressList) Add(address Address) int

func (*InternetAddressList) Append

func (l *InternetAddressList) Append(newList AddressList)

func (*InternetAddressList) Clear

func (l *InternetAddressList) Clear()

func (*InternetAddressList) Contains

func (l *InternetAddressList) Contains(address Address) bool

func (*InternetAddressList) GetAddress

func (l *InternetAddressList) GetAddress(index int) Address

func (*InternetAddressList) GetLength

func (l *InternetAddressList) GetLength() int

func (*InternetAddressList) IndexOf

func (l *InternetAddressList) IndexOf(address Address) int

func (*InternetAddressList) Insert

func (l *InternetAddressList) Insert(address Address, index int)

func (*InternetAddressList) Prepend

func (l *InternetAddressList) Prepend(newList AddressList)

func (*InternetAddressList) Remove

func (l *InternetAddressList) Remove(address Address) bool

func (*InternetAddressList) RemoveAt

func (l *InternetAddressList) RemoveAt(index int) bool

func (*InternetAddressList) SetAddress

func (l *InternetAddressList) SetAddress(address Address, index int)

func (*InternetAddressList) Slice

func (l *InternetAddressList) Slice() []Address

func (*InternetAddressList) ToString

func (l *InternetAddressList) ToString(encode bool) string

func (*InternetAddressList) Walk

func (l *InternetAddressList) Walk(callback func(Address))

type Janitor

type Janitor interface {
	// contains filtered or unexported methods
}

Janitor to clean up wasteful resources

type MD5Filter

type MD5Filter interface {
	Filter
	GetDigest() []byte
}

type Mailbox

type Mailbox interface {
	Address
	Email() string
	SetEmail(string)
}

type MailboxAddress

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

func CastMailboxAddress

func CastMailboxAddress(ma *C.InternetAddressMailbox) *MailboxAddress

func NewMailboxAddress

func NewMailboxAddress(name string, email string) *MailboxAddress

func (*MailboxAddress) Email

func (a *MailboxAddress) Email() string

func (MailboxAddress) Name

func (a MailboxAddress) Name() string

func (*MailboxAddress) SetEmail

func (a *MailboxAddress) SetEmail(email string)

func (MailboxAddress) SetName

func (a MailboxAddress) SetName(name string)

type MemStream

type MemStream interface {
	Stream
	Bytes() []byte
}

func NewMemStream

func NewMemStream() MemStream

func NewMemStreamWithBuffer

func NewMemStreamWithBuffer(str string) MemStream

type Message

type Message interface {
	Object
	SetSender(string)
	Sender() (string, bool)
	SetReplyTo(string)
	ReplyTo() (string, bool)
	SetSubject(string)
	Subject() (string, bool)
	SetMessageId(string)
	MessageId() (string, bool)
	DateAsString() (string, bool)
	SetDateAsString(string)
	AddTo(string, string)
	To() *InternetAddressList
	AddCc(string, string)
	Cc() *InternetAddressList
	AddBcc(string, string)
	Bcc() *InternetAddressList
	AllRecipients() *InternetAddressList
	SetMimePart(Object)
	MimePart() Object
	Body() Object
	Date() string
}

func NewMessage

func NewMessage() Message

type MessagePart

type MessagePart interface {
	Object
	Message() Message
	SetMessage(message Message)
}

func CastMessagePart

func CastMessagePart(mp *C.GMimeMessagePart) MessagePart

func NewMessagePart

func NewMessagePart(subtype string) MessagePart

func NewMessagePartWithMessage

func NewMessagePartWithMessage(subtype string, message Message) MessagePart

type MessagePartial

type MessagePartial interface {
	Object
	Id() string
	Number() int
	Total() int
}

func CastMessagePartial

func CastMessagePartial(mp *C.GMimeMessagePartial) MessagePartial

func NewMessagePartial

func NewMessagePartial(id string, number int, total int) MessagePartial

type Multipart

type Multipart interface {
	Object
	AddPart(Object)
	Boundary() string
	GetPart(int) Object
	Count() int
	Clear()
	Walk(func(Object) error) error
}

func CastMultipart

func CastMultipart(mp *C.GMimeMultipart) Multipart

func NewMultipart

func NewMultipart() Multipart

func NewMultipartWithSubtype

func NewMultipartWithSubtype(subtype string) Multipart

type NullStream

type NullStream interface {
	Stream
	Newlines() int64
}

func NewNullStream

func NewNullStream() NullStream

type Object

type Object interface {
	Janitor
	SetContentType(ContentType)
	ContentType() ContentType
	SetHeader(string, string)
	Header(string) (string, bool)
	ToString() string
	ContentDisposition() ContentDisposition
	Headers() string
	WriteToStream(Stream) int
	WalkHeaders(cb func(string, string) error) error
}

func NewObject

func NewObject(contentType ContentType) Object

func NewObjectWithType

func NewObjectWithType(ctype string, csubtype string) Object

type Parametrized

type Parametrized interface {
	SetParameter(name, value string)
	Parameter(name string) string
	ForEachParam(callback GMimeParamsCallback)
}

type Parse

type Parse interface {
	To() string
	Subject() (string, bool)
	From() (string, bool)
	Bcc() string
	Cc() string
	Recipients() string
	MessageId() (string, bool)
	Text() (string, bool)
	Html() (string, bool)
	Attachment() map[string][]byte
	//	AttachmentReader() Reader
	Headers() string
	Header(string) (string, bool)
	Boundary() string
}

func NewParse

func NewParse(reader io.Reader) Parse
Example

Example on how to create a NewParse

fileHandler, _ := os.Open("fixtures/text_attachment.eml")
defer fileHandler.Close()
reader := bufio.NewReader(fileHandler)
parse := NewParse(reader)

from, _ := parse.From()
subject, _ := parse.Subject()
fmt.Println(from)
fmt.Println(parse.To())
fmt.Println(subject)
Output:

Dave McGuire <foobar@foobar.com>
Team R&D <foobar@foobar.com>
Distilled Content-Type headers (outbound & failed)

type Parser

type Parser interface {
	Janitor
	ConstructMessage() Message
	ConstructPart() Object
	Tell() int64
	Eos() bool
	SetScanFrom(bool)
}

func CastParser

func CastParser(p *C.GMimeParser) Parser

func NewParserWithStream

func NewParserWithStream(stream Stream) Parser

type Part

type Part interface {
	Object
	ContentObject() DataWrapper
	SetContentObject(DataWrapper)
	Filename() string
	Description() string
	ContentLocation() string
	ContentEncoding() string
	SetContentEncoding(encoding string)
}

func NewPart

func NewPart() Part

func NewPartWithType

func NewPartWithType(ctype string, csubtype string) Part

type PartIter

type PartIter interface {
	Current() Object
	HasNext() bool
	Next()
}

func NewPartIter

func NewPartIter(message Message) PartIter

type PointerMixin

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

func CastPointer

func CastPointer(p C.gpointer) *PointerMixin

func NewPointer

func NewPointer(p C.gpointer) *PointerMixin

for newly allocated only

type Stream

type Stream interface {
	Janitor
	Read(int64) (int64, []byte)
	Write([]byte) int64
	WriteBlock([]byte, int64) int64
	Flush() int
	Close() int
	Eos() bool
	Reset() int
	Seek(int64, int) (int64, error)
	Tell() int64
	Length() int64
	SubStream(int64, int64) Stream
	SetBounds(int64, int64)
	WriteString(string) int64
	WriteToStream(Stream) int64
}

Jump to

Keyboard shortcuts

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