7 "github.com/mjl-/mox/smtp"
10// ParseAddressList parses a string as an address list header value
11// (potentially multiple addresses, comma-separated, with optional display
13func ParseAddressList(s string) ([]Address, error) {
14 parser := mail.AddressParser{WordDecoder: &wordDecoder}
15 addrs, err := parser.ParseList(s)
17 return nil, fmt.Errorf("parsing address list: %v", err)
19 r := make([]Address, len(addrs))
20 for i, a := range addrs {
21 addr, err := smtp.ParseNetMailAddress(a.Address)
23 return nil, fmt.Errorf("parsing adjusted address %q: %v", a.Address, err)
25 r[i] = Address{a.Name, addr.Localpart.String(), addr.Domain.ASCII}