Gathering detailed insights and metrics for @emailjs/browser
Gathering detailed insights and metrics for @emailjs/browser
Gathering detailed insights and metrics for @emailjs/browser
Gathering detailed insights and metrics for @emailjs/browser
npm install @emailjs/browser
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
115 Stars
246 Commits
11 Forks
4 Watching
2 Branches
1 Contributors
Updated on 25 Nov 2024
Minified
Minified + Gzipped
TypeScript (90.51%)
JavaScript (5.76%)
HTML (3.25%)
Shell (0.48%)
Cumulative downloads
Total Downloads
Last day
6.6%
6,160
Compared to previous day
Last week
4.4%
36,375
Compared to previous week
Last month
7%
153,505
Compared to previous month
Last year
30.1%
1,615,287
Compared to previous year
SDK for EmailJS.com customers.
Use your EmailJS account for sending emails.
This is a browser platform, otherwise use
EmailJS helps you send emails directly from code with one command. No server is required – just connect EmailJS to one of the supported email services, create an email template, and use our SDK to trigger an email.
Install EmailJS SDK using npm:
1$ npm install @emailjs/browser
Or manually:
1<script 2 type="text/javascript" 3 src="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js"> 4</script> 5<script type="text/javascript"> 6 (function () { 7 emailjs.init({ 8 publicKey: 'YOUR_PUBLIC_KEY', 9 }); 10 })(); 11</script>
Send the email using the customized send method
1var templateParams = { 2 name: 'James', 3 notes: 'Check this out!', 4}; 5 6emailjs.send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', templateParams).then( 7 function (response) { 8 console.log('SUCCESS!', response.status, response.text); 9 }, 10 function (err) { 11 console.log('FAILED...', err); 12 }, 13);
Send the email from a form using the sendForm method
1emailjs.sendForm('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', '#myForm').then( 2 function (response) { 3 console.log('SUCCESS!', response.status, response.text); 4 }, 5 function (err) { 6 console.log('FAILED...', err); 7 }, 8);
Using Angular / VueJS / ReactJS / Svelte / any other modern framework
1import emailjs from '@emailjs/browser'; 2 3const templateParams = { 4 name: 'James', 5 notes: 'Check this out!', 6}; 7 8emailjs 9 .send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', templateParams, { 10 publicKey: 'YOUR_PUBLIC_KEY', 11 }) 12 .then( 13 (response) => { 14 console.log('SUCCESS!', response.status, response.text); 15 }, 16 (err) => { 17 console.log('FAILED...', err); 18 }, 19 );
await/async with EmailJS error handler
1import emailjs, { EmailJSResponseStatus } from '@emailjs/browser'; 2 3try { 4 await emailjs.send( 5 'YOUR_SERVICE_ID', 6 'YOUR_TEMPLATE_ID', 7 {}, 8 { 9 publicKey: 'YOUR_PUBLIC_KEY', 10 }, 11 ); 12 console.log('SUCCESS!'); 13} catch (err) { 14 if (err instanceof EmailJSResponseStatus) { 15 console.log('EMAILJS FAILED...', err); 16 return; 17 } 18 19 console.log('ERROR', err); 20}
Options
Options can be declared globally using the init method or locally as the fourth parameter of a function.
The local parameter will have higher priority than the global one.
Name | Type | Default | Description |
---|---|---|---|
publicKey | String | The public key is required to invoke the method. | |
blockHeadless | Boolean | False | Method will return error 451 if the browser is headless. |
blockList | BlockList | Block list settings. | |
limitRate | LimitRate | Limit rate configuration. | |
storageProvider | StorageProvider | Provider for a custom key-value storage. |
BlockList
Allows to ignore a method call if the watched variable contains a value from the block list.
The method will return the error 403 if the request is blocked.
Name | Type | Description |
---|---|---|
list | String[] | The array of strings contains values for blocking. |
watchVariable | String | A name of the variable to be watched. |
LimitRate
Allows to set the limit rate for calling a method.
If the request hits the limit rate, the method will return the error 429.
Name | Type | Default | Description |
---|---|---|---|
id | String | page path | The limit rate is per page by default. To override the behavior, set the ID. It can be a custom ID for each page, group, or application. |
throttle | Number | (ms) After how many milliseconds a next request is allowed. |
StorageProvider
Allows to provide a custom key value storage. By default, localStorage is used if available.
The custom provider must match the interface.
1interface StorageProvider { 2 get: (key: string) => Promise<string | null | undefined>; 3 set: (key: string, value: string) => Promise<void>; 4 remove: (key: string) => Promise<void>; 5}
Declare global settings
1import emailjs from '@emailjs/browser'; 2 3emailjs.init({ 4 publicKey: 'YOUR_PUBLIC_KEY', 5 blockHeadless: true, 6 blockList: { 7 list: ['foo@emailjs.com', 'bar@emailjs.com'], 8 }, 9 limitRate: { 10 throttle: 10000, // 10s 11 }, 12});
Overwrite settings locally
1import emailjs from '@emailjs/browser'; 2 3const templateParams = { 4 name: 'James', 5 notes: 'Check this out!', 6}; 7 8emailjs 9 .send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', templateParams, { 10 publicKey: 'YOUR_PUBLIC_KEY', 11 blockList: { 12 watchVariable: 'userEmail', 13 }, 14 limitRate: { 15 throttle: 0, // turn off the limit rate for these requests 16 }, 17 }) 18 .then( 19 (response) => { 20 console.log('SUCCESS!', response.status, response.text); 21 }, 22 (err) => { 23 console.log('FAILED...', err); 24 }, 25 );
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More