parse-email-address - v0.0.5
    Preparing search index...

    Function parseEmailAddress

    • Parse a single RFC 5321 email address into parts. This is the strict, envelope-level grammar: it accepts nothing but a bare user@domain. To read an address out of an RFC 5322 message header (which may carry display names, comments, groups, and multiple addresses), use parseEmailAddressList or parseHeaderEmailAddress instead.

      This uses parse from smtp-address-parser v1.1.0.

      Parameters

      • emailAddress: string | undefined

      Returns ParsedEmailAddress | undefined

      undefined if the given email address is invalid.

      import {parseEmailAddress} from 'parse-email-address';

      const result1 = parseEmailAddress('simple@example.org');
      // result1 is `{user: 'simple', domain: 'example.org', full: 'simple@example.org'}`

      const result2 = parseEmailAddress('tld-too-short@foo.x');
      // result2 is `undefined`

      const result3 = parseEmailAddress('Simple Person <simple@example.org>');
      // result3 is `undefined`

      Nothing, this will never throw an error.