
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
@emailjs/nodejs
Advanced tools
SDK for EmailJS.com customers.
Use your EmailJS account for sending emails.
This is a Node.js platform, otherwise use
EmailJS helps you send emails directly from code with one command. No large knowledge 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:
$ npm install @emailjs/nodejs
Note: By default, API requests are disabled for non-browser applications. You need to activate them through Account:Security.
You need to activate API requests through Account:Security.
Send the email using the customized send method
import emailjs from '@emailjs/nodejs';
const templateParams = {
name: 'James',
notes: 'Check this out!',
};
emailjs
.send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', templateParams, {
publicKey: 'YOUR_PUBLIC_KEY',
privateKey: 'YOUR_PRIVATE_KEY', // optional, highly recommended for security reasons
})
.then(
(response) => {
console.log('SUCCESS!', response.status, response.text);
},
(err) => {
console.log('FAILED...', err);
},
);
init (optional)
import emailjs from '@emailjs/nodejs';
// set Public Key as global settings
emailjs.init({
publicKey: 'YOUR_PUBLIC_KEY',
privateKey: 'YOUR_PRIVATE_KEY', // optional, highly recommended for security reasons
});
emailjs.send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID').then(
(response) => {
console.log('SUCCESS!', response.status, response.text);
},
(err) => {
console.log('FAILED...', err);
},
);
await/async with EmailJS error handler
import emailjs, { EmailJSResponseStatus } from '@emailjs/nodejs';
try {
await emailjs.send(
'YOUR_SERVICE_ID',
'YOUR_TEMPLATE_ID',
{},
{
publicKey: 'YOUR_PUBLIC_KEY',
privateKey: 'YOUR_PRIVATE_KEY', // optional, highly recommended for security reasons
},
);
console.log('SUCCESS!');
} catch (err) {
if (err instanceof EmailJSResponseStatus) {
console.log('EMAILJS FAILED...', err);
return;
}
console.log('ERROR', err);
}
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. | |
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.
interface StorageProvider {
get: (key: string) => Promise<string | null | undefined>;
set: (key: string, value: string) => Promise<void>;
remove: (key: string) => Promise<void>;
}
Declare global settings
import emailjs from '@emailjs/nodejs';
emailjs.init({
publicKey: 'YOUR_PUBLIC_KEY',
privateKey: 'YOUR_PRIVATE_KEY', // optional, highly recommended for security reasons
blockList: {
list: ['foo@emailjs.com', 'bar@emailjs.com'],
},
limitRate: {
throttle: 10000, // 10s
},
});
Overwrite settings locally
import emailjs from '@emailjs/nodejs';
const templateParams = {
name: 'James',
notes: 'Check this out!',
};
emailjs
.send('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', templateParams, {
publicKey: 'YOUR_PUBLIC_KEY',
privateKey: 'YOUR_PRIVATE_KEY', // optional, highly recommended for security reasons
blockList: {
watchVariable: 'userEmail',
},
limitRate: {
throttle: 0, // turn off the limit rate for these requests
},
})
.then(
(response) => {
console.log('SUCCESS!', response.status, response.text);
},
(err) => {
console.log('FAILED...', err);
},
);
FAQs
Official EmailJS SDK for NodeJS
The npm package @emailjs/nodejs receives a total of 4,466 weekly downloads. As such, @emailjs/nodejs popularity was classified as popular.
We found that @emailjs/nodejs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.