universal-create-mailto-href
v1.0.1
Published
A typed and tested function to generate Mailto links in any environment(universal).
Downloads
5
Maintainers
Readme
universal-create-mailto-href
Help your users send meaningful emails from your application with just one click
Install
npm install universal-create-mailto-href
Sending emails can be a chore. You have to figure out who to send it to, decide if anyone needs to be on CC or even BCC, put a meaningful subject and of course write the body.
As developers we can help our users with this struggle! By thinking of who our users want to reach and what they want to say we can create powerful templates by just using HTML links and a bit of creativity. Normally this requires some string interpolation, headscratching and looking out for edge cases, so why not use this fully tested package to help you along?
no information lost in URI encodings or typos in string interpolation
Basic usage
import { createMailtolHref } from 'universal-create-mailto-href';
const href = createMailtolHref({
emails: ['[email protected]'],
cc: ['[email protected]'],
subject: 'I need help'
})
// mailto:[email protected][email protected]
Advanced usage
import { createMailtolHref } from 'universal-create-mailto-href';
const href = createMailtolHref({
emails: ['[email protected]', '[email protected]'],
cc: ['[email protected]'],
bcc: ['[email protected]', '[email protected]', '[email protected]', '[email protected]' ],
subject: 'Hello everyone!',
body: 'What do you think about feature X?'
})
// mailto:[email protected],[email protected][email protected]&[email protected],[email protected],[email protected],[email protected]&subject=Hello%20everyone!&body=What%20do%20you%20think%20about%20feature%20X%3F
Let me know what you build!
Kris