Imports #
"bufio"
"errors"
"fmt"
"io"
"log"
"mime"
"net"
"net/textproto"
"strings"
"sync"
"time"
"unicode/utf8"
"bufio"
"errors"
"fmt"
"io"
"log"
"mime"
"net"
"net/textproto"
"strings"
"sync"
"time"
"unicode/utf8"
var ErrHeaderNotPresent = *ast.CallExpr
Layouts suitable for passing to time.Parse. These are tried in order.
var dateLayouts []string
Layouts suitable for passing to time.Parse. These are tried in order.
var dateLayoutsBuildOnce sync.Once
var debug = *ast.CallExpr
var rfc2047Decoder = mime.WordDecoder{...}
A Header represents the key-value pairs in a mail message header.
type Header map[string][]string
type charsetError string
type debugT bool
Address represents a single mail address.
An address such as "Barry Gibbs
type Address struct {
Name string
Address string
}
An AddressParser is an RFC 5322 address parser.
type AddressParser struct {
WordDecoder *mime.WordDecoder
}
A Message represents a parsed mail message.
type Message struct {
Header Header
Body io.Reader
}
type addrParser struct {
s string
dec *mime.WordDecoder
}
AddressList parses the named header field as a list of addresses.
func (h Header) AddressList(key string) ([]*Address, error)
Date parses the Date header field.
func (h Header) Date() (time.Time, error)
func (e charsetError) Error() string
Get gets the first value associated with the given key. It is case insensitive; CanonicalMIMEHeaderKey is used to canonicalize the provided key. If there are no values associated with the key, Get returns "". To access multiple values of a key, or to use non-canonical keys, access the map directly.
func (h Header) Get(key string) string
Parse parses a single RFC 5322 address of the
form "Gogh Fir
func (p *AddressParser) Parse(address string) (*Address, error)
ParseAddress parses a single RFC 5322 address, e.g. "Barry Gibbs
func ParseAddress(address string) (*Address, error)
ParseAddressList parses the given string as a list of addresses.
func ParseAddressList(list string) ([]*Address, error)
ParseDate parses an RFC 5322 date string.
func ParseDate(date string) (time.Time, error)
ParseList parses the given string as a list of comma-separated addresses
of the form "Gogh Fir
func (p *AddressParser) ParseList(list string) ([]*Address, error)
func (d debugT) Printf(format string, args ...any)
ReadMessage reads a message from r. The headers are parsed, and the body of the message will be available for reading from msg.Body.
func ReadMessage(r io.Reader) (msg *Message, err error)
String formats the address as a valid RFC 5322 address. If the address's name contains non-ASCII characters the name will be rendered according to RFC 2047.
func (a *Address) String() string
func buildDateLayouts()
func (p *addrParser) consume(c byte) bool
consumeAddrSpec parses a single RFC 5322 addr-spec at the start of p.
func (p *addrParser) consumeAddrSpec() (spec string, err error)
consumeAtom parses an RFC 5322 atom at the start of p. If dot is true, consumeAtom parses an RFC 5322 dot-atom instead. If permissive is true, consumeAtom will not fail on: - leading/trailing/double dots in the atom (see golang.org/issue/4938)
func (p *addrParser) consumeAtom(dot bool, permissive bool) (atom string, err error)
func (p *addrParser) consumeComment() (string, bool)
func (p *addrParser) consumeDisplayNameComment() (string, error)
consumeDomainLiteral parses an RFC 5322 domain-literal at the start of p.
func (p *addrParser) consumeDomainLiteral() (string, error)
func (p *addrParser) consumeGroupList() ([]*Address, error)
consumePhrase parses the RFC 5322 phrase at the start of p.
func (p *addrParser) consumePhrase() (phrase string, err error)
consumeQuotedString parses the quoted string at the start of p.
func (p *addrParser) consumeQuotedString() (qs string, err error)
func (p *addrParser) decodeRFC2047Word(s string) (word string, isEncoded bool, err error)
func (p *addrParser) empty() bool
isAtext reports whether r is an RFC 5322 atext character. If dot is true, period is included.
func isAtext(r rune, dot bool) bool
isDtext reports whether r is an RFC 5322 dtext character.
func isDtext(r rune) bool
isMultibyte reports whether r is a multi-byte UTF-8 character as supported by RFC 6532.
func isMultibyte(r rune) bool
isQtext reports whether r is an RFC 5322 qtext character.
func isQtext(r rune) bool
isVchar reports whether r is an RFC 5322 VCHAR character.
func isVchar(r rune) bool
isWSP reports whether r is a WSP (white space). WSP is a space or horizontal tab (RFC 5234 Appendix B).
func isWSP(r rune) bool
func (p *addrParser) len() int
parseAddress parses a single RFC 5322 address at the start of p.
func (p *addrParser) parseAddress(handleGroup bool) ([]*Address, error)
func (p *addrParser) parseAddressList() ([]*Address, error)
func (p *addrParser) parseSingleAddress() (*Address, error)
func (p *addrParser) peek() byte
quoteString renders a string as an RFC 5322 quoted-string.
func quoteString(s string) string
readHeader reads the message headers from r. This is like textproto.ReadMIMEHeader, but doesn't validate. The fix for issue #53188 tightened up net/textproto to enforce restrictions of RFC 7230. This package implements RFC 5322, which does not have those restrictions. This function copies the relevant code from net/textproto, simplified for RFC 5322.
func readHeader(r *textproto.Reader) (map[string][]string, error)
skipCFWS skips CFWS as defined in RFC5322.
func (p *addrParser) skipCFWS() bool
skipSpace skips the leading space and tab characters.
func (p *addrParser) skipSpace()
Generated with Arrow