Documentation
¶
Index ¶
- Constants
- type Address
- type AddressField
- type AddressParser
- type AddressType
- type Addresses
- type BoringType
- type ContentDisposition
- type ContentLanguage
- type ContentTransferEncoding
- type ContentType
- type DateField
- type EncodedTextType
- type EncodingType
- type Field
- type Header
- func (h *Header) Add(key, value string)
- func (h *Header) Addresses(fn string) []Address
- func (h *Header) AsText(avoidUTF8 bool) string
- func (h *Header) ContentDescription() string
- func (h *Header) ContentDisposition() *ContentDisposition
- func (h *Header) ContentLanguage() *ContentLanguage
- func (h *Header) ContentLocation() string
- func (h *Header) ContentTransferEncoding() *ContentTransferEncoding
- func (h *Header) ContentType() *ContentType
- func (h *Header) Date() *time.Time
- func (h *Header) Get(key string) string
- func (h *Header) MarshalJSON() ([]byte, error)
- func (h *Header) MessageID() string
- func (h *Header) Remove(r Field)
- func (h *Header) RemoveAllNamed(name string)
- func (h *Header) RemoveAt(i int)
- func (h *Header) Repair()
- func (h *Header) RepairWithBody(p *Part, body string)
- func (h *Header) Simplify()
- func (h *Header) Subject() string
- func (h *Header) ToMap() map[string][]string
- func (h *Header) UnmarshalJSON(data []byte) error
- func (h *Header) Valid() bool
- type HeaderField
- type HeaderFieldCondition
- type MIMEField
- type MIMEParameter
- type Message
- type Part
Constants ¶
const ( FromFieldName = "From" ResentFromFieldName = "Resent-From" SenderFieldName = "Sender" ResentSenderFieldName = "Resent-Sender" ReturnPathFieldName = "Return-Path" ReplyToFieldName = "Reply-To" ToFieldName = "To" CcFieldName = "Cc" BccFieldName = "Bcc" ResentToFieldName = "Resent-To" ResentCcFieldName = "Resent-Cc" ResentBccFieldName = "Resent-Bcc" MessageIDFieldName = "Message-ID" ResentMessageIDFieldName = "Resent-Message-ID" InReplyToFieldName = "In-Reply-To" ReferencesFieldName = "References" DateFieldName = "Date" OrigDateFieldName = "Orig-Date" ResentDateFieldName = "Resent-Date" SubjectFieldName = "Subject" CommentsFieldName = "Comments" KeywordsFieldName = "Keywords" ContentTypeFieldName = "Content-Type" ContentTransferEncodingFieldName = "Content-Transfer-Encoding" ContentDispositionFieldName = "Content-Disposition" ContentDescriptionFieldName = "Content-Description" ContentIDFieldName = "Content-ID" MIMEVersionFieldName = "MIME-Version" ReceivedFieldName = "Received" ContentLanguageFieldName = "Content-Language" ContentLocationFieldName = "Content-Location" ContentMd5FieldName = "Content-Md5" ListIdFieldName = "List-Id" ContentBaseFieldName = "Content-Base" ErrorsToFieldName = "Errors-To" )
const ( RFC5322Header headerMode = iota MIMEHeader )
const ( TextPlainContentType defaultContentType = iota // default MessageRFC822ContentType )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
func NewAddress ¶
type AddressField ¶
type AddressField struct { HeaderField Addresses Addresses }
func NewAddressField ¶
func NewAddressField(name string) *AddressField
func (*AddressField) Parse ¶
func (f *AddressField) Parse(s string)
func (*AddressField) Value ¶
func (f *AddressField) Value() string
type AddressParser ¶
type AddressParser struct { Addresses Addresses // contains filtered or unexported fields }
The AddressParser class helps parse email addresses and lists.
In the interests of simplicity, AddressParser parses everything as if it were a list of addresses - either of the mailbox-list or address-list productions in RFC 2822. The user of this class must check that the supplied addresses fit the (often more specific) requirements.
AddressParser supports most of RFC 822 and 2822, but mostly omits address groups. An empty address group is translated into a single Address, a nonempty group is translated into the equivalent number of addresses.
AddressParser does not attempt to canonicalize the addresses parsed or get rid of duplicates (To: ams@oryx.com, ams@ory.com), it only parses.
The first error seen is stored and can be accessed using error().
func NewAddressParser ¶
func NewAddressParser(s string) AddressParser
Constructs an Address Parser parsing \a s. After construction, addresses() and error() may be accessed immediately.
type AddressType ¶
type AddressType int
const ( NormalAddressType AddressType = iota BounceAddressType EmptyGroupAddressType LocalAddressType InvalidAddressType )
type BoringType ¶
type BoringType int
const ( TotallyBoring BoringType = iota IMAPBoring MIMEBoring )
type ContentDisposition ¶
func NewContentDisposition ¶
func NewContentDisposition() *ContentDisposition
func (*ContentDisposition) Parse ¶
func (f *ContentDisposition) Parse(s string)
type ContentLanguage ¶
func NewContentLanguage ¶
func NewContentLanguage() *ContentLanguage
func (*ContentLanguage) Parse ¶
func (f *ContentLanguage) Parse(s string)
type ContentTransferEncoding ¶
type ContentTransferEncoding struct { MIMEField Encoding EncodingType }
func NewContentTransferEncoding ¶
func NewContentTransferEncoding() *ContentTransferEncoding
func (*ContentTransferEncoding) Parse ¶
func (f *ContentTransferEncoding) Parse(s string)
type ContentType ¶
func NewContentType ¶
func NewContentType() *ContentType
func (*ContentType) Parse ¶
func (f *ContentType) Parse(s string)
type DateField ¶
type DateField struct { HeaderField Date *time.Time }
func NewDateField ¶
func NewDateField() *DateField
type EncodedTextType ¶
type EncodedTextType int
const ( EncodedText EncodedTextType = iota EncodedComment EncodedPhrase )
type EncodingType ¶
type EncodingType int
const ( QPEncoding EncodingType = iota Base64Encoding UuencodeEncoding BinaryEncoding )
type Field ¶
type Field interface { Name() string Value() string Error() error Parse(value string) Valid() bool UnparsedValue() string SetUnparsedValue(value string) // contains filtered or unexported methods }
func NewHeaderField ¶
func NewHeaderFieldNamed ¶
type Header ¶
type Header struct { Fields []Field // contains filtered or unexported fields }
func ReadHeader ¶
func (*Header) Add ¶
Add adds the key, value pair to the header. It appends to any existing values associated with the key.
func (*Header) Addresses ¶
Returns a pointer to the addresses in the \a t header field, which must be an address field such as From or Bcc. If not, or if the field is empty, addresses() returns a null pointer.
func (*Header) AsText ¶
Returns the canonical text representation of this Header. Downgrades rather than including UTF-8 if \a avoidUTF8 is true.
func (*Header) ContentDescription ¶
Returns the value of the Content-Description field, or an empty string if there isn't one. RFC 2047 encoding is not considered - should it be?
func (*Header) ContentDisposition ¶
func (h *Header) ContentDisposition() *ContentDisposition
Returns a pointer to the Content-Disposition header field, or a null pointer if there isn't one.
func (*Header) ContentLanguage ¶
func (h *Header) ContentLanguage() *ContentLanguage
Returns a pointer to the Content-Language header field, or a null pointer if there isn't one.
func (*Header) ContentLocation ¶
Returns the value of the Content-Location field, or an empty string if there isn't one. The URI is not validated in any way.
func (*Header) ContentTransferEncoding ¶
func (h *Header) ContentTransferEncoding() *ContentTransferEncoding
Returns a pointer to the Content-Transfer-Encoding header field, or a null pointer if there isn't one.
func (*Header) ContentType ¶
func (h *Header) ContentType() *ContentType
Returns a pointer to the Content-Type header field, or a null pointer if there isn't one.
func (*Header) Date ¶
Returns the header's data \a t, which is the normal date by default, but can also be orig-date or resent-date. If there is no such field or \a t is meaningless, date() returns a null pointer.
func (*Header) Get ¶
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "".
func (*Header) MarshalJSON ¶
func (*Header) MessageID ¶
Returns the value of the Message-ID field, or an empty string if there isn't one or if there are multiple (which is illegal).
func (*Header) RemoveAllNamed ¶
func (*Header) Repair ¶
func (h *Header) Repair()
Repairs problems that can be repaired without knowing the associated bodypart.
func (*Header) RepairWithBody ¶
Repairs a few harmless and common problems, such as inserting two Date fields with the same value. Assumes that \a p is its companion body (whose text is in \a body), and may look at it to decide what/how to repair.
func (*Header) Simplify ¶
func (h *Header) Simplify()
Removes any redundant header fields from this header, and simplifies the value of some.
For example, if 'sender' or 'reply-to' points to the same address as 'from', that field can be removed, and if 'from' contains the same address twice, one can be removed.
func (*Header) Subject ¶
Returns the value of the first Subject header field. If there is no such field, returns the empty string.
func (*Header) UnmarshalJSON ¶
type HeaderField ¶
type HeaderField struct {
// contains filtered or unexported fields
}
func (*HeaderField) Error ¶
func (f *HeaderField) Error() error
func (*HeaderField) Name ¶
func (f *HeaderField) Name() string
func (*HeaderField) Parse ¶
func (f *HeaderField) Parse(s string)
Every HeaderField subclass must define a parse() function that takes a string \a s from a message and sets the field value(). This default function handles fields that are not specially handled by subclasses using functions like parseText().
func (*HeaderField) SetUnparsedValue ¶
func (f *HeaderField) SetUnparsedValue(value string)
func (*HeaderField) UnparsedValue ¶
func (f *HeaderField) UnparsedValue() string
func (*HeaderField) Valid ¶
func (f *HeaderField) Valid() bool
Returns true if this header field is valid (or unparsed, as is the case for all unknown fields), and false if an error was detected during parsing.
func (*HeaderField) Value ¶
func (f *HeaderField) Value() string
type HeaderFieldCondition ¶
type HeaderFieldCondition struct {
// contains filtered or unexported fields
}
type MIMEField ¶
type MIMEField struct { HeaderField Parameters []MIMEParameter // contains filtered or unexported fields }
type MIMEParameter ¶
func NewMIMEParameter ¶
func NewMIMEParameter(name, value string) MIMEParameter
type Message ¶
func NewMessage ¶
func NewMessage() *Message
func ReadMessage ¶
func (*Message) BodyPart ¶
Returns a pointer to the Bodypart whose IMAP part number is \a s and possibly create it. Creates Bodypart objects if \a create is true. Returns null pointer if \a s is not valid and \a create is false.
type Part ¶
type Part struct { Header *Header `json:"header"` Parts []*Part `json:"parts,omitempty"` Number int `json:"-"` Text string `json:"text,omitempty"` Data string `json:"data,omitempty"` // contains filtered or unexported fields }
func (*Part) AsText ¶
Returns the text representation of this Bodypart.
Notes: This function seems uncomfortable. It returns just one of many possible text representations, and the exact choice seems arbitrary, and finally, it does rather overlap with text() and data().
We probably should transition away from this function.
The exact representation returned uses base64 encoding for data types and no ContentTransferEncoding. For text types, it encodes the text according to the ContentType.