react-mailto.js
v3.0.3
Published
React MailTo component for easy creation of fully configured mailto links
Downloads
295
Maintainers
Readme
react-mailto.js
Install
npm install react-mailto.js --save
Usage
Import the package to your script:
import Mailto from 'react-mailto.js';Add <Mailto /> component to your code and use properties described below to config your link:
| Property | Type | Example | Description |
| --------- | ----------------------------------------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| to | string or Array<string>, isRequired | '[email protected]', ['[email protected]', '[email protected]'] | Email to this person, or multiple persons |
| subject | string | 'This is title' | Your email Subject |
| body | string | 'This is body of my email' | Your email body |
| cc | string or Array<string> | '[email protected]', ['[email protected]', '[email protected]'] | CC email to this person, or multiple persons |
| bcc | string or Array<string> | '[email protected]', ['[email protected]', '[email protected]'] | BCC email to this person, or multiple persons |
| secure | boolean | true | When is set to true href of the link will be set to javascript:void(0) to not to leak email to the HTML code |
Simple config
<Mailto
secure={true}
to="[email protected]"
subject="Some email subject"
body={['This is the body of your message', 'Multilined also'].join('\n')}
>
email us
</Mailto>Full config
<Mailto
secure={true}
to={['[email protected]', '[email protected]']}
cc={['[email protected]', '[email protected]']}
bcc={['[email protected]', '[email protected]']}
subject="Some email subject"
body={[
'Some body',
'Multilined also',
'Symbols: ,./!@#$%^&*()_+~`":;<>?',
"<script>console.log('xss');</script>"
].join('\n')}
onClick={(e) => {
console.log(e);
}}
>
email us
</Mailto>