@mxraven/mail - v0.6.0
    Preparing search index...

    Function parseAddressList

    • Parses a comma-separated RFC 5322 address list and expands its groups.

      Use this for a header value such as To, Cc, or Reply-To, where one field may carry several mailboxes. Every entry is parsed and normalized exactly like parseAddress, so the same length limits, domain rules, and encoded-word decoding apply.

      Parameters

      • input: string

        The address-list text. Empty or whitespace-only input yields an empty array.

      Returns MailboxAddress[]

      The mailboxes in source order, with groups expanded. The result is a fresh mutable array of immutable mailboxes owned by the caller.

      A group contributes its member mailboxes and its own display name is discarded, because RFC 5322 does not make the group name part of any member. An empty group such as undisclosed-recipients:; contributes no addresses, which is how a sender hides a recipient list.

      The obsolete list grammar permits commas before the first address, which is accepted. Empty elements between addresses and a trailing comma are rejected: they cannot name a recipient, and dropping them silently would hide a broken header. To inspect a header that may be malformed, split it yourself and call parseAddress per entry.

      AddressError When an entry is not a valid mailbox. AddressError.kind identifies the first failure.

      import { parseAddressList } from "@mxraven/mail";

      const mailboxes = parseAddressList(
      'Friends: "Doe, John" <j@example.com>, a@例え.jp;',
      );
      mailboxes.map((mailbox) => mailbox.domain);
      // ["example.com", "xn--r8jz45g.jp"]