{"id":34502480,"url":"https://github.com/wildduck2/email-toolkit","last_synced_at":"2025-12-24T02:10:23.955Z","repository":{"id":250810918,"uuid":"835541628","full_name":"wildduck2/email-toolkit","owner":"wildduck2","description":"it's a TypeScript library for building and manipulating MIME (Multipurpose Internet Mail Extensions) messages. This library provides an easy-to-use API for creating, modifying, and encoding MIME messages, making it ideal for email and other internet-based communication systems.","archived":false,"fork":false,"pushed_at":"2025-05-25T10:09:55.000Z","size":206,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-08T13:19:08.707Z","etag":null,"topics":["base64","decoding","email","encoding","mimebundle","textdecoder","textencoder","typescript","uri-encoding","utility"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wildduck2.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2024-07-30T03:51:11.000Z","updated_at":"2025-05-25T10:09:58.000Z","dependencies_parsed_at":"2025-05-13T08:12:48.436Z","dependency_job_id":"47c43a45-fbdc-4a64-829a-ed9ea9af0d3e","html_url":"https://github.com/wildduck2/email-toolkit","commit_stats":null,"previous_names":["wildduck2/-wild-duck-mime-builder","wildduck2/email-toolkit","wildduck2/email-builder"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/wildduck2/email-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildduck2%2Femail-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildduck2%2Femail-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildduck2%2Femail-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildduck2%2Femail-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wildduck2","download_url":"https://codeload.github.com/wildduck2/email-toolkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildduck2%2Femail-toolkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27992996,"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","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["base64","decoding","email","encoding","mimebundle","textdecoder","textencoder","typescript","uri-encoding","utility"],"created_at":"2025-12-24T02:10:23.299Z","updated_at":"2025-12-24T02:10:23.945Z","avatar_url":"https://github.com/wildduck2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@ahmedayob/email-toolkit`\n\nA powerful and flexible toolkit for building, validating, and processing emails with TypeScript. This library offers utilities for handling email headers, attachments, and encoding, making it easier to compose and manage emails programmatically.\n\n## Features\n\n- **Email Header Management**: Easily create and manage email headers.\n- **Attachment Handling**: Add, validate, and format email attachments.\n- **Encoding Utilities**: Encode content in Base64 for attachments.\n- **Validation**: Ensure email content, headers, and attachments are valid with built-in validation schemas.\n- **Custom Error Handling**: Handle email-related errors with a custom `EmailError` class.\n\n## Installation\n\nTo install the toolkit, use npm or yarn:\n\n```bash\nnpm install @ahmedayob/email-toolkit\n# or\nyarn add @ahmedayob/email-toolkit\n```\n\n## Usage\n\nHere's a quick guide on how to use the library:\n\n### Email Header\n\nCreate and configure email headers:\n\n```typescript\nimport { EmailBuilderHeader } from \"@ahmedayob/email-toolkit\";\n\nconst header = new EmailBuilderHeader();\nheader\n  .setFrom(\"ahmed \u003cahmed@gmail.com\u003e\")\n  .setTo(\"ahmed \u003cahmed@gmail.com\u003e\")\n  .setCc(\"ahmed \u003cahmed@gmail.com\u003e\")\n  .setBcc(\"ahmed \u003cahmed@gmail.com\u003e\")\n  .setSubject(\"This is a test email subject\")\n  .setInReplyTo(\"ahmed@gmail.com\")\n  .setMIMEVersion(\"1.0\")\n  .setContentTransferEncoding(\"quoted-printable\")\n  .setContentType(\"text/html\")\n  .setCharset(\"utf-8\");\n```\n\n### Email Attachment\n\nAdd attachments to your email:\n\n```typescript\nimport { EmailBuilderAttachment, Base64 } from \"@ahmedayob/email-toolkit\";\n\nconst attachment = new EmailBuilderAttachment();\nattachment.addAttachment({\n  headers: {\n    \"Content-Type\": 'text/plain; charset=\"utf-8\"',\n    \"Content-Transfer-Encoding\": \"base64\",\n    \"Content-Disposition\": 'attachment; filename=\"test.txt\"',\n  },\n  size: 1234,\n  filename: \"test.txt\",\n  mimeType: \"text/plain\",\n  attachmentId: \"1234\",\n  attachmentContent: Base64.encodeToBase64(\n    \"This is the content of the attachment.\"\n  ),\n});\n```\n\n### Building the Email\n\nCombine headers and attachments to create the final email:\n\n```typescript\nimport { EmailBuilder } from \"@ahmedayob/email-toolkit\";\n\nconst email = new EmailBuilder();\nemail.messagebody = \"\u003cp\u003eThis is the message body\u003c/p\u003e\";\n\nconst finalEmail = email.getRawMessage(header.headers, attachment.attachments);\nconsole.log(finalEmail);\n```\n\n### Encoding and Signature\n\nGenerate base64-encoded messages and email signatures:\n\n```typescript\nimport { EmailBuilder } from \"@ahmedayob/email-toolkit\";\n\nconst email = new EmailBuilder();\nemail.messagebody = \"\u003cp\u003eThis is the message body\u003c/p\u003e\";\n\nconst encodedMessage = email.getEncodedMessage(\n  header.headers,\n  attachment.attachments\n);\nconsole.log(encodedMessage);\n\nemail.setSignature({\n  url: \"https://github.com/wildduck2\",\n  name: \"Ahmed Ayob\",\n});\n\nconst signature = email.getSignature({\n  from: \"ahmed@example.com\",\n  url: \"https://github.com/wildduck2\",\n  name: \"Ahmed Ayob\",\n});\nconsole.log(signature.join(\"\\n\"));\n```\n\n## API\n\n### `EmailBuilderHeader`\n\n- **setFrom**(address: string): Sets the \"From\" header.\n- **setTo**(address: string): Sets the \"To\" header.\n- **setCc**(address: string): Sets the \"Cc\" header.\n- **setBcc**(address: string): Sets the \"Bcc\" header.\n- **setSubject**(subject: string): Sets the email subject.\n- **setInReplyTo**(messageId: string): Sets the \"In-Reply-To\" header.\n- **setMIMEVersion**(version: string): Sets the \"MIME-Version\" header.\n- **setContentTransferEncoding**(encoding: string): Sets the \"Content-Transfer-Encoding\" header.\n- **setContentType**(type: string): Sets the \"Content-Type\" header.\n- **setCharset**(charset: string): Sets the charset.\n\n### `EmailBuilderAttachment`\n\n- **addAttachment**(attachment: AttachmentType): Adds an attachment.\n- **getAttachment**(): Retrieves the formatted attachments.\n\n### `EmailBuilder`\n\n- **messagebody**: Sets the body of the email.\n- **getRawMessage**(headers: HeadersType, attachments?: AttachmentType[]): Gets the raw email message.\n- **getEncodedMessage**(headers: HeadersType, attachments?: AttachmentType[]): Gets the base64-encoded email message.\n- **getSignature**(signatureDetails: GetSignatureType): Generates a formatted signature block.\n- **setSignature**(signatureDetails: NonNullableType\u003cOmit\u003cGetSignatureType, \"from\"\u003e\u003e): Sets the email signature details.\n\n### `Base64`\n\n- **encodeToBase64**(data: string): Encodes data to Base64.\n\n### `EmailError`\n\n- **name**: The name of the error.\n- **description**: A description of the error.\n- **constructor**({ message, description }: { message: string; description: string }): Constructs a new `EmailError`.\n\n## Validation\n\nValidation schemas are available to ensure data correctness:\n\n- **HeadersTypeSchema**: Validates email headers.\n- **AttachmentHeaderSchema**: Validates attachment headers.\n- **StringSchema**: Validates strings.\n- **ContentTransferEncodingSchema**: Validates content transfer encodings.\n- **ContentTypeSchema**: Validates content types.\n- **CharsetTypeSchema**: Validates charset types.\n\n## Contributing\n\nContributions are welcome! Please open issues and pull requests on the [GitHub repository](https://github.com/ahmedayob/email-toolkit).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildduck2%2Femail-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwildduck2%2Femail-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildduck2%2Femail-toolkit/lists"}