少于1分钟
https://pkg.go.dev/net/mail@go1.20.1
Package mail implements parsing of mail messages.
For the most part, this package follows the syntax as specified by RFC 5322 and extended by RFC 6532. Notable divergences:
- Obsolete address formats are not parsed, including addresses with embedded route information.
- The full range of spacing (the CFWS syntax element) is not supported, such as breaking addresses across lines.
- No unicode normalization is performed.
- The special characters ()[]:;@, are allowed to appear unquoted in names.
常量
This section is empty.
变量
| |
函数
func ParseDate <- go1.8
| |
ParseDate parses an RFC 5322 date string.
类型
type Address
| |
Address represents a single mail address. An address such as “Barry Gibbs bg@example.com” is represented as Address{Name: “Barry Gibbs”, Address: “bg@example.com”}.
func ParseAddress <- go1.1
| |
ParseAddress parses a single RFC 5322 address, e.g. “Barry Gibbs bg@example.com”
Example
| |
func ParseAddressList <- go1.1
| |
ParseAddressList parses the given string as a list of addresses.
Example
| |
(*Address) String
| |
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.
type AddressParser <- go1.5
| |
An AddressParser is an RFC 5322 address parser.
(*AddressParser) Parse <- go1.5
| |
Parse parses a single RFC 5322 address of the form “Gogh Fir gf@example.com” or “foo@example.com”.
(*AddressParser) ParseList <- go1.5
| |
ParseList parses the given string as a list of comma-separated addresses of the form “Gogh Fir gf@example.com” or “foo@example.com”.
type Header
| |
A Header represents the key-value pairs in a mail message header.
(Header) AddressList
| |
AddressList parses the named header field as a list of addresses.
(Header) Date
| |
Date parses the Date header field.
(Header) Get
| |
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.
type Message
| |
A Message represents a parsed mail message.
func ReadMessage
| |
ReadMessage reads a message from r. The headers are parsed, and the body of the message will be available for reading from msg.Body.
Example
| |