Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
coins-mail
Advanced tools
HTML and text email templates for COINS.
The createMail
is coins-mail’s chief export. It expects a configured Bookshelf.js model:
const knex = require('knex')({
/* DB config ... */
});
const bookshelf = require('bookshelf')(knex);
const createMail = require('coins-mail').createMail;
const MyMailModel = bookshelf.Model.extend({
tableName: 'my_table_name',
});
createMail(MyMailModel, options); // returns Promise
createMail
returns a Promise. In the case of a single mail option, this is the result of calling save
on a Bookshelf.js model. In the case of a collection of mail options, this is the result of invoking save
on the Bookshelf collection.
options
can be either a mail options object or a collection of these objects:
fromLabel
(string): Added to the from_label
column. This is typically the name of application sending the email.recipients
(string or array of strings): Single recipient email address or a collection of email addresses.replyTo
(string): Email address to use in the email’s 'reply to' field.subject
(string): Email’s subject field.templateLocals
(object): Hash to pass to getTemplate
. The keys/values depend on the email template in use (see templateName
).sendTime
(string, defaults to Date.now()
): Time to send the email.templateName
(string, defaults to “default“): Name of email template to use. createMail(MyMailModel, {
fromLabel: 'Test Application',,
recipients: [
'recipient-1@mrn.org',
'recipeint-2@mrn.org',
'recipient-3@mrn.org',
// ...
],
replyTo: 'reply-address@mrn.org',
sendTime: Date.now() + 24 * 60 * 60 * 1000,
subject: 'Test Subject',
templateLocals: {
html: {
myHtmlTemplateVar: 'value',
},
text: {
myTextTemplateVar: 'value',
},
},
templateName: 'my-template',
})
.then(savedModel => console.log(savedModel))
.catch(error => console.error(error));
createMail(MyMailModel, [{
fromLabel: 'Test Application 1',
recipients: 'recipient-1@mrn.org'
replyTo: 'reply-address@mrn.org',
subject: 'Test Subject 1',
templateLocals: // ...
}, {
fromLabel: 'Test Application 2',
recipients: 'recipient-2@mrn.org'
replyTo: 'reply-address@mrn.org',
subject: 'Test Subject 2',
templateLocals: // ...
}, {
fromLabel: 'Test Application 3',
recipients: 'recipient-3@mrn.org'
replyTo: 'reply-address@mrn.org',
subject: 'Test Subject 3',
templateLocals: // ...
}])
.then(savedModels => {
savedModels.forEach(savedModel => console.log(savedModel));
})
.catch(error => console.error(error));
const getTemplate = require('coins-mail').getTemplate;
getTemplate({
html: {
myHtmlTemplateVar: '<h1>Hi!</h1> <p>Insert this html…</p>',
},
text: {
myTextTemplateVar: 'Alternative!\n\nFor the text version…',
},
}, (error, result) => {
if (error) {
console.error(error);
} else {
console.log('HTML:', result.html);
console.log('Text:', result.text);
}
});
getTemplate
also returns a Promise
:
getTemplate(myLocals)
.then(result => {
console.log('HTML:', result.html);
console.log('Text:', result.text);
})
.catch(error => console.error(error));
MIT. See LICENSE for details.
FAQs
HTML and text email templates for COINS.
We found that coins-mail demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.