{"id":21650896,"url":"https://github.com/iansinnott/mailstring","last_synced_at":"2025-04-11T20:23:36.208Z","repository":{"id":47385476,"uuid":"67136487","full_name":"iansinnott/mailstring","owner":"iansinnott","description":"Generate mailto strings for fun and profit. Also a React component 📤","archived":false,"fork":false,"pushed_at":"2022-12-04T13:26:42.000Z","size":430,"stargazers_count":5,"open_issues_count":8,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T16:21:45.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/iansinnott.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}},"created_at":"2016-09-01T14:04:34.000Z","updated_at":"2023-03-17T14:38:00.000Z","dependencies_parsed_at":"2023-01-23T01:01:08.926Z","dependency_job_id":null,"html_url":"https://github.com/iansinnott/mailstring","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansinnott%2Fmailstring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansinnott%2Fmailstring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansinnott%2Fmailstring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansinnott%2Fmailstring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iansinnott","download_url":"https://codeload.github.com/iansinnott/mailstring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473663,"owners_count":21109750,"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":[],"created_at":"2024-11-25T07:45:52.875Z","updated_at":"2025-04-11T20:23:36.177Z","avatar_url":"https://github.com/iansinnott.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mailstring\n\n[![Build Status](https://img.shields.io/circleci/project/iansinnott/mailstring.svg)](https://circleci.com/gh/iansinnott/mailstring)\n[![react-string-replace.js on NPM](https://img.shields.io/npm/v/mailstring.svg)](https://www.npmjs.com/package/mailstring)\n\n\u003e Generate `mailto:` strings for fun and profit\n\n## Install\n\n```\n$ npm install --save mailstring\n```\n\n\n## Usage\n\n**ES6**\n\n```js\nimport { mailTo } from 'mailstring';\n\nmailTo('name@email.com');\n// =\u003e 'mailto:name@email.com'\n\nmailTo('name@email.com,other@example.com');\n// =\u003e 'mailto:name@email.com,other@example.com';\n\nmailTo('name@email.com', {\n  cc: 'other@email.com',\n  bcc: 'fun@email.com',\n  subject: 'hello',\n  body: 'something',\n});\n// =\u003e 'mailto:name@email.com?cc=other@email.com\u0026bcc=fun@email.com\u0026subject=hello\u0026body=something';\n```\n\n**CommonJS / Node**\n\n```js\nconst mailTo = require('mailstring').mailTo;\n```\n\n## API\n\n**NOTE:** The `mailto:` API only allows you to set defaults in a new email window. The user can manually change any of the values you provide once the email window has opened.\n\n### mailTo(address, [options])\n\n#### address\n\nType: `string`\n\nEmail address or list of email addresses to prepopulate when the user clicks the link. Multiple email addresses should be comma-separated.\n\n#### options\n\n##### cc\n\nType: `string`\n\nEmail address(es) to add to the CC field in the email window.\n\n##### bcc\n\nType: `string`\n\nEmail address(es) to add to the BCC field in the email window.\n\n##### subject\n\nType: `string`\n\nSubject to prepopulate in the email window. Special characters will be escaped using `encodeURIComponent`.\n\n##### body\n\nType: `string`\n\nEmail body to prepopulate in the email window. Special characters will be escaped using `encodeURIComponent`. The `body` may contain multiple paragraphs separated by newlines, however, not every email client supports this. For example, in my testing newlines are supported fine in Apple Mail but not in Nylas N1. Just keep this in mind and if in doubt test out your link in the client of your choice.\n\n### `mailstring/react`\n\nMailstring also exports a React component for your convenience if using React. Don't worry, React is not bundled with mailstring so you will not bloat your codebase by simply requiring the `mailTo` function, and if you do wish to use the React component you will need React installed as a peerDependency.\n\n#### Usage\n\nSee the [example/](./example) directory for the full example.\n\n```js\nimport React from 'react';\nimport { render } from 'react-dom';\n\n// Import the React Component\nimport { MailToLink } from 'mailstring/react';\n\nconst body = `\nDear so and so,\n\nThis is a nice multiline message. It contains more than one paragraph.\n\nPretty slick, eh?\n\n- Person\n`.trim();\n\nclass App extends React.Component {\n  render() {\n    return (\n      \u003cdiv className='App'\u003e\n        \u003ch1\u003eHey there\u003c/h1\u003e\n        \u003cMailToLink\n          to='ian@example.com'\n          cc='first@example.com,second@example.com'\n          bcc='third@example.com'\n          subject='Nice to meet you'\n          body={body}\n        \u003e\n          Email Me\n        \u003c/MailToLink\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n```\n\n## TODO\n\n- [ ] Do not package React with the `mailstring/react` component\n- [ ] Test MailToLink using enzyme\n- [ ] Document MailToLink\n\n## License\n\nMIT © [Ian Sinnott](https://www.iansinnott.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiansinnott%2Fmailstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiansinnott%2Fmailstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiansinnott%2Fmailstring/lists"}