{"id":19670342,"url":"https://github.com/mat-sz/letterparser","last_synced_at":"2025-10-16T08:34:31.688Z","repository":{"id":51979138,"uuid":"252222909","full_name":"mat-sz/letterparser","owner":"mat-sz","description":"✉️ Isomorphic e-mail parser (with MIME support) written in TypeScript.","archived":false,"fork":false,"pushed_at":"2024-09-19T16:24:10.000Z","size":226,"stargazers_count":45,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-14T17:04:51.896Z","etag":null,"topics":["email","isomorphic","javascript","javascript-library","mail","mime","mime-parser","parser","typescript","typescript-library"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause-clear","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mat-sz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-01T16:02:45.000Z","updated_at":"2025-03-14T10:13:29.000Z","dependencies_parsed_at":"2024-01-11T21:03:51.969Z","dependency_job_id":"342bf18a-623c-48c8-be69-05c81a60982b","html_url":"https://github.com/mat-sz/letterparser","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":"0.016949152542372836","last_synced_commit":"9897abfec2aee47b6c8d0cf7f2d01dd1f8a75022"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat-sz%2Fletterparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat-sz%2Fletterparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat-sz%2Fletterparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat-sz%2Fletterparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mat-sz","download_url":"https://codeload.github.com/mat-sz/letterparser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244973772,"owners_count":20541025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","isomorphic","javascript","javascript-library","mail","mime","mime-parser","parser","typescript","typescript-library"],"created_at":"2024-11-11T17:05:58.969Z","updated_at":"2025-10-16T08:34:26.628Z","avatar_url":"https://github.com/mat-sz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/mat-sz/letterparser/master/logo.png\" alt=\"letterparser\" width=\"700\"\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg alt=\"workflow\" src=\"https://img.shields.io/github/actions/workflow/status/mat-sz/letterparser/node.js.yml?branch=master\"\u003e\n\u003ca href=\"https://npmjs.com/package/letterparser\"\u003e\n\u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/letterparser\"\u003e\n\u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/dw/letterparser\"\u003e\n\u003cimg alt=\"NPM\" src=\"https://img.shields.io/npm/l/letterparser\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n**letterparser** is a parser library created for parsing e-mail messages. The library is written in TypeScript, fully supports both browser and server environments. The performance may not be the best at the current stage of development, parsing large messages is not recommended.\n\nThis library was created as an isomorphic alternative for [mailparser](https://github.com/nodemailer/mailparser).\n\nThe following RFCs are supported (or will be) by letterparser:\n\n- [RFC 5322](https://tools.ietf.org/html/rfc5322.html)\n- [RFC 6532](https://tools.ietf.org/html/rfc6532.html)\n- [RFC 2046](https://tools.ietf.org/html/rfc2046.html)\n\nParsing multipart and plain text messages is currently working, although the output is raw. A function for extracting the most commonly used data will be added in a future release.\n\n| Builder                                                  | SMTP client/server                                 |\n| -------------------------------------------------------- | -------------------------------------------------- |\n| [letterbuilder](https://github.com/mat-sz/letterbuilder) | [@typemail/smtp](https://github.com/typemail/smtp) |\n\n## Usage\n\n\u003e **WARNING!** [node.js built with full ICU is required](https://nodejs.org/api/intl.html). (full-icu NPM package may work as a substitute, although this is not recommended.)\n\u003e\n\u003e By default, recent node.js versions ship full ICU binaries. Incomplete ICU will result in bad encoding errors.\n\n### General information\n\nTo get information about the message, use `extract`:\n\n```js\nimport { extract } from 'letterparser';\nlet res = extract(`Date: Wed, 01 Apr 2020 00:00:00 -0000\nFrom: A \u003ca@example.com\u003e\nTo: B \u003cb@example.com\u003e\nSubject: Hello world!\nMime-Version: 1.0\nContent-Type: text/plain; charset=utf-8\n\nSome message.`);\n```\n\nThe function returns `LetterparserMail`:\n\n```ts\nexport interface LetterparserMailbox {\n  name?: string;\n  address: string;\n  raw: string;\n}\n\nexport interface LetterparserAttachment {\n  contentType: LetterparserContentType;\n  body: string | Uint8Array;\n  contentId?: string;\n  filename?: string;\n}\n\nexport interface LetterparserMail {\n  subject?: string;\n  to?: LetterparserMailbox[];\n  cc?: LetterparserMailbox[];\n  bcc?: LetterparserMailbox[];\n  from?: LetterparserMailbox;\n  attachments?: LetterparserAttachment[];\n  html?: string;\n  text?: string;\n  amp?: string;\n}\n```\n\n### Message structure\n\nThe library also exports a `parse` function that outputs the raw structure of the message.\n\n```js\nimport { parse } from 'letterparser';\nlet node = parse(`Date: Wed, 01 Apr 2020 00:00:00 -0000\nFrom: A \u003ca@example.com\u003e\nTo: B \u003cb@example.com\u003e\nSubject: Hello world!\nMime-Version: 1.0\nContent-Type: text/plain; charset=utf-8\n\nSome message.`);\n```\n\nThe return value of that function is `LetterparserNode`, as defined below:\n\n```ts\ninterface LetterparserContentType {\n  type: string;\n  encoding?: string;\n  parameters: Headers;\n}\n\ninterface LetterparserNode {\n  contentType: LetterparserContentType;\n  headers: Headers;\n  body: LetterparserNode | LetterparserNode[] | string | Uint8Array;\n}\n```\n\nHeaders names are normalized to be camel case with dashes.\n\nE.g.\n\n`Content-ID` becomes `Content-Id`\n\n`content-type` becomes `Content-Type`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmat-sz%2Fletterparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmat-sz%2Fletterparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmat-sz%2Fletterparser/lists"}