var debug … type debugT … func (d debugT) Printf(format string, args ...any) { … } type Message … // 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) { … } // 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) { … } var dateLayoutsBuildOnce … var dateLayouts … func buildDateLayouts() { … } // ParseDate parses an RFC 5322 date string. func ParseDate(date string) (time.Time, error) { … } type Header … // 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 { … } var ErrHeaderNotPresent … // Date parses the Date header field. func (h Header) Date() (time.Time, error) { … } // AddressList parses the named header field as a list of addresses. func (h Header) AddressList(key string) ([]*Address, error) { … } type Address … // ParseAddress parses a single RFC 5322 address, e.g. "Barry Gibbs <[email protected]>" func ParseAddress(address string) (*Address, error) { … } // ParseAddressList parses the given string as a list of addresses. func ParseAddressList(list string) ([]*Address, error) { … } type AddressParser … // Parse parses a single RFC 5322 address of the // form "Gogh Fir <[email protected]>" or "[email protected]". func (p *AddressParser) Parse(address string) (*Address, error) { … } // ParseList parses the given string as a list of comma-separated addresses // of the form "Gogh Fir <[email protected]>" or "[email protected]". func (p *AddressParser) ParseList(list string) ([]*Address, 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 { … } type addrParser … func (p *addrParser) parseAddressList() ([]*Address, error) { … } func (p *addrParser) parseSingleAddress() (*Address, error) { … } // parseAddress parses a single RFC 5322 address at the start of p. func (p *addrParser) parseAddress(handleGroup bool) ([]*Address, error) { … } func (p *addrParser) consumeGroupList() ([]*Address, error) { … } // consumeAddrSpec parses a single RFC 5322 addr-spec at the start of p. func (p *addrParser) consumeAddrSpec() (spec string, err 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) { … } // 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) { … } // consumeDomainLiteral parses an RFC 5322 domain-literal at the start of p. func (p *addrParser) consumeDomainLiteral() (string, error) { … } func (p *addrParser) consumeDisplayNameComment() (string, error) { … } func (p *addrParser) consume(c byte) bool { … } // skipSpace skips the leading space and tab characters. func (p *addrParser) skipSpace() { … } func (p *addrParser) peek() byte { … } func (p *addrParser) empty() bool { … } func (p *addrParser) len() int { … } // skipCFWS skips CFWS as defined in RFC5322. func (p *addrParser) skipCFWS() bool { … } func (p *addrParser) consumeComment() (string, bool) { … } func (p *addrParser) decodeRFC2047Word(s string) (word string, isEncoded bool, err error) { … } var rfc2047Decoder … type charsetError … func (e charsetError) Error() string { … } // isAtext reports whether r is an RFC 5322 atext character. // If dot is true, period is included. func isAtext(r rune, dot bool) bool { … } // isQtext reports whether r is an RFC 5322 qtext character. func isQtext(r rune) bool { … } // quoteString renders a string as an RFC 5322 quoted-string. func quoteString(s string) string { … } // isVchar reports whether r is an RFC 5322 VCHAR character. func isVchar(r rune) bool { … } // isMultibyte reports whether r is a multi-byte UTF-8 character // as supported by RFC 6532. func isMultibyte(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 { … } // isDtext reports whether r is an RFC 5322 dtext character. func isDtext(r rune) bool { … }