Documentation ¶
Overview ¶
Package gmime implements the MIME, port of C GMime
Index ¶
- Constants
- func AssignJanitor(self Janitor)
- func CastBufferedStream(cs *C.GMimeStream) *aBufferedStream
- func CastContentDisposition(c *C.GMimeContentDisposition) *aContentDisposition
- func CastDataWrapper(dw *C.GMimeDataWrapper) *aDataWrapper
- func CastFileStream(cfs *C.GMimeStreamFile) *aFileStream
- func CastMemStream(cms *C.GMimeStreamMem) *aMemStream
- func CastMessage(m *C.GMimeMessage) *aMessage
- func CastNullStream(cms *C.GMimeStreamNull) *aNullStream
- func CastObject(o *C.GMimeObject) *anObject
- func CastPart(p *C.GMimePart) *aPart
- func CastStream(cs *C.GMimeStream) *aStream
- func MewFromFilter(flags int) *aFilter
- func NewBasicFilter(encoding string, encode bool) *aFilter
- func NewBestFilter(flags int) *aBestFilter
- func NewCRLFFilter(encode bool, dots bool) *aFilter
- func NewCharsetFilter(source string, target string) *aFilter
- func NewContentDispositionFromString(str string) *aContentDisposition
- func NewEnrichedFilter(flags int32) *aFilter
- func NewGZipFilter(mode int, level int) *aFilter
- func NewHTMLFilter(flags uint32, colour int32) *aFilter
- func NewMD5Filter() *aFilterMD5
- func NewStripFilter() *aFilter
- func NewYEncFilter(encode bool) *aFilter
- func Shutdown()
- type Address
- type AddressList
- type BufferedStream
- type Compose
- type ContentDisposition
- type ContentEncodingState
- type ContentType
- type DataWrapper
- type FileStream
- type Filter
- type FilterBest
- type FilterFullLowlevelInterface
- type FsStream
- type GMimeParamsCallback
- type Group
- type GroupAddress
- type HeaderIterator
- type InternetAddressList
- func (l *InternetAddressList) Add(address Address) int
- func (l *InternetAddressList) Append(newList AddressList)
- func (l *InternetAddressList) Clear()
- func (l *InternetAddressList) Contains(address Address) bool
- func (l *InternetAddressList) GetAddress(index int) Address
- func (l *InternetAddressList) GetLength() int
- func (l *InternetAddressList) IndexOf(address Address) int
- func (l *InternetAddressList) Insert(address Address, index int)
- func (l *InternetAddressList) Prepend(newList AddressList)
- func (l *InternetAddressList) Remove(address Address) bool
- func (l *InternetAddressList) RemoveAt(index int) bool
- func (l *InternetAddressList) SetAddress(address Address, index int)
- func (l *InternetAddressList) Slice() []Address
- func (l *InternetAddressList) ToString(encode bool) string
- func (l *InternetAddressList) Walk(callback func(Address))
- type Janitor
- type MD5Filter
- type Mailbox
- type MailboxAddress
- type MemStream
- type Message
- type MessagePart
- type MessagePartial
- type Multipart
- type NullStream
- type Object
- type Parametrized
- type Parse
- type Parser
- type Part
- type PartIter
- type PointerMixin
- type Stream
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 ( CACHE_READ = C.GMIME_STREAM_BUFFER_CACHE_READ BLOCK_READ = C.GMIME_STREAM_BUFFER_BLOCK_READ BLOCK_WRITE = C.GMIME_STREAM_BUFFER_BLOCK_WRITE )
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 CastStream ¶
func CastStream(cs *C.GMimeStream) *aStream
func MewFromFilter ¶
func MewFromFilter(flags int) *aFilter
func NewBasicFilter ¶
func NewBestFilter ¶
func NewBestFilter(flags int) *aBestFilter
func NewCRLFFilter ¶
func NewCharsetFilter ¶
func NewContentDispositionFromString ¶
func NewContentDispositionFromString(str string) *aContentDisposition
func NewEnrichedFilter ¶
func NewEnrichedFilter(flags int32) *aFilter
func NewGZipFilter ¶
func NewHTMLFilter ¶
func NewMD5Filter ¶
func NewMD5Filter() *aFilterMD5
func NewStripFilter ¶
func NewStripFilter() *aFilter
func NewYEncFilter ¶
func NewYEncFilter(encode bool) *aFilter
Types ¶
type Address ¶
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 ¶
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 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 ¶
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 FilterBest ¶
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 ¶
func NewFsStream ¶
type GMimeParamsCallback ¶
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) SetMembers ¶
func (group *GroupAddress) SetMembers(list AddressList)
type HeaderIterator ¶
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 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) SetEmail ¶
func (a *MailboxAddress) SetEmail(email string)
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 ¶
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 ¶
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 ¶
type NullStream ¶
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 ¶
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 ¶
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 ¶
type Part ¶
type Part interface { Object ContentObject() DataWrapper SetContentObject(DataWrapper) Filename() string Description() string ContentLocation() string ContentEncoding() string SetContentEncoding(encoding string) }
func NewPartWithType ¶
type PartIter ¶
func NewPartIter ¶
type PointerMixin ¶
type PointerMixin struct {
// contains filtered or unexported fields
}
func CastPointer ¶
func CastPointer(p C.gpointer) *PointerMixin
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 }
Source Files ¶
- compose.go
- content_disposition.go
- content_type.go
- data_wrapper.go
- doc.go
- encodings.go
- filter.go
- gmime.go
- internet_address.go
- janitor.go
- message.go
- message_part.go
- message_partial.go
- multipart.go
- object.go
- param.go
- parse.go
- parser.go
- part.go
- part_iter.go
- stream.go
- stream_buffer.go
- stream_file.go
- stream_fs.go
- stream_mem.go
- stream_null.go
Click to show internal directories.
Click to hide internal directories.