diff options
Diffstat (limited to 'src/pkg/net/mail/message.go')
-rw-r--r-- | src/pkg/net/mail/message.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pkg/net/mail/message.go b/src/pkg/net/mail/message.go index b610ccf3f..96c796e78 100644 --- a/src/pkg/net/mail/message.go +++ b/src/pkg/net/mail/message.go @@ -47,7 +47,8 @@ type Message struct { } // ReadMessage reads a message from r. -// The headers are parsed, and the body of the message will be reading from r. +// The headers are parsed, and the body of the message will be available +// for reading from r. func ReadMessage(r io.Reader) (msg *Message, err error) { tp := textproto.NewReader(bufio.NewReader(r)) @@ -126,7 +127,7 @@ func (h Header) AddressList(key string) ([]*Address, error) { if hdr == "" { return nil, ErrHeaderNotPresent } - return newAddrParser(hdr).parseAddressList() + return ParseAddressList(hdr) } // Address represents a single mail address. @@ -137,6 +138,16 @@ type Address struct { Address string // user@domain } +// Parses a single RFC 5322 address, e.g. "Barry Gibbs <bg@example.com>" +func ParseAddress(address string) (*Address, error) { + return newAddrParser(address).parseAddress() +} + +// ParseAddressList parses the given string as a list of addresses. +func ParseAddressList(list string) ([]*Address, error) { + return newAddrParser(list).parseAddressList() +} + // 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. |