
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Compose beautiful multilingual emails with XHTML templates and Nodemailer integration.
| Template | French | English | Use Case |
|---|---|---|---|
password-reset | ✅ | ✅ | Password reset emails |
account-creation | ✅ | ✅ | Welcome new users |
suspicious-login | ✅ | ✅ | Security alerts |
subscription-confirmation | ✅ | ✅ | Newsletter subscriptions |
newsletter-promotion | ✅ | ✅ | Marketing campaigns |
scheduled-maintenance | ✅ | ✅ | System notifications |
npm install composa
import { EmailClient, defaultSubjects } from 'composa';
const mailer = new EmailClient({
defaultLang: 'fr',
subjects: defaultSubjects,
transport: {
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: 'your-email@gmail.com',
pass: 'your-app-password'
}
}
});
// Send a password reset email
const result = await mailer.sendTemplate({
to: 'user@example.com',
template: 'password-reset',
lang: 'fr',
variables: {
USER_NAME: 'Jean Dupont',
USER_EMAIL: 'user@example.com',
RESET_URL: 'https://yourapp.com/reset/token123',
EXPIRATION_TIME: '24 heures'
}
});
console.log('Email sent:', result);
const mailer = new EmailClient(options);
| Option | Type | Description |
|---|---|---|
defaultLang | string | Default language ('fr', 'en') |
subjects | Map | Email subjects by template and language |
defaults | object | Default variables for all templates |
transport | object | Nodemailer transport configuration |
transporter | object | Custom Nodemailer transporter instance |
sendTemplate(options)Send an email using a template.
await mailer.sendTemplate({
to: 'recipient@example.com',
template: 'password-reset',
lang: 'fr',
variables: {
USER_NAME: 'User Name',
// ... other variables
}
});
sendBulk(recipients, mailOptions)Send the same email to multiple recipients.
await mailer.sendBulk(
['user1@example.com', 'user2@example.com'],
{
template: 'newsletter-promotion',
lang: 'fr',
variables: { PROMO_CODE: 'SAVE20' }
}
);
Each template supports specific variables. Here are the common ones:
USER_NAME - Recipient's nameUSER_EMAIL - Recipient's emailRESET_URL - Password reset linkEXPIRATION_TIME - Link expiration timeUSER_NAME - New user's nameUSER_EMAIL - New user's emailACTIVATION_URL - Account activation linkAPP_URL - Your application URLUSER_NAME - User's nameLOGIN_TIME - Time of suspicious loginIP_ADDRESS - Source IP addressLOCATION - Geographic locationSECURE_URL - Security settings URLThe package comes with built-in French and English templates. You can extend with your own languages:
// Add custom subjects
mailer.registerSubjects('password-reset', {
'es': 'Restablecer contraseña',
'de': 'Passwort zurücksetzen'
});
// Create custom templates in templates/es-ES/ or templates/de-DE/
Composa makes email provider setup super easy with dedicated helper functions. No more complex SMTP configurations!
import { EmailClient, defaultSubjects, createGmailConfig } from 'composa';
// Gmail - just 2 parameters!
const mailer = new EmailClient({
defaultLang: 'fr',
subjects: defaultSubjects,
transport: createGmailConfig('your@gmail.com', 'your-app-password')
});
// That's it! No need to remember SMTP settings.
| Function | Provider | What you need |
|---|---|---|
createGmailConfig(email, appPassword) | Gmail | Gmail address + App Password |
createOutlookConfig(email, password) | Outlook/Hotmail | Outlook address + password |
createYahooConfig(email, appPassword) | Yahoo | Yahoo address + App Password |
createSendGridConfig(apiKey) | SendGrid | Just your API key |
createMailgunConfig(domain, apiKey) | Mailgun | Domain + API key |
createTestConfig(user, pass) | Ethereal (testing) | Test credentials |
import {
EmailClient,
defaultSubjects,
createGmailConfig,
createOutlookConfig,
createSendGridConfig
} from 'composa';
// Gmail setup (requires App Password)
const gmailMailer = new EmailClient({
defaultLang: 'fr',
subjects: defaultSubjects,
transport: createGmailConfig('me@gmail.com', 'myapppassword123')
});
// Outlook setup (simple password)
const outlookMailer = new EmailClient({
defaultLang: 'en',
subjects: defaultSubjects,
transport: createOutlookConfig('me@outlook.com', 'mypassword')
});
// SendGrid setup (just API key)
const sendgridMailer = new EmailClient({
defaultLang: 'en',
subjects: defaultSubjects,
transport: createSendGridConfig('SG.your-api-key-here')
});
Get step-by-step instructions for any provider:
import { getProviderSetup } from 'composa';
// Get Gmail setup instructions
const gmailSetup = getProviderSetup('gmail');
console.log(gmailSetup.setupSteps);
/*
[
"1. Enable 2-Factor Authentication on your Google account",
"2. Go to Google Account settings > Security > 2-Step Verification",
"3. Generate an 'App Password' for 'Mail'",
"4. Use your Gmail address and the App Password"
]
*/
For complete control, use the full configuration:
import { createProviderConfig } from 'composa';
const customConfig = createProviderConfig('gmail', {
user: 'your@gmail.com',
pass: 'your-app-password'
}, {
// Optional: advanced settings
pool: true,
maxConnections: 5,
rateLimit: 10
});
For providers not included in presets:
const mailer = new EmailClient({
defaultLang: 'fr',
subjects: defaultSubjects,
transport: {
host: 'mail.yourserver.com',
port: 465,
secure: true,
auth: {
user: 'noreply@yourserver.com',
pass: 'your-password'
}
}
});
You can also use environment variables:
SMTP_HOST=smtp.gmail.com
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-app-password
// Will automatically use environment variables
const mailer = new EmailClient({
defaultLang: 'fr',
subjects: defaultSubjects
});
Composa supports custom email templates for your specific needs.
your-project/
├── templates/
│ ├── en-EN/
│ │ ├── welcome.xhtml
│ │ └── invoice.xhtml
│ └── fr-FR/
│ ├── welcome.xhtml
│ └── invoice.xhtml
import { EmailClient } from 'composa';
const mailer = new EmailClient({
templatesPath: './my-templates', // Path to your templates
defaultLang: 'en'
});
// Use your custom template
await mailer.sendTemplate({
to: 'user@example.com',
template: 'welcome', // Corresponds to welcome.xhtml
variables: {
USER_NAME: 'John Doe',
APP_NAME: 'MyApp'
}
});
<!DOCTYPE html>
<html>
<head>
<title>{{APP_NAME}}</title>
<style>
.container { max-width: 600px; margin: 0 auto; }
.button { background-color: #007bff; color: white; }
</style>
</head>
<body>
<div class="container">
<h1>Hello {{USER_NAME}}!</h1>
<p>Welcome to {{APP_NAME}}.</p>
<a href="{{ACTIVATION_URL}}" class="button">
Activate Account
</a>
</div>
</body>
</html>
Register subjects for your custom templates:
// Register subjects for custom templates
mailer.registerSubjects('welcome', {
'en': 'Welcome to {{APP_NAME}}!',
'fr': 'Bienvenue sur {{APP_NAME}} !'
});
// Or use in constructor
const customSubjects = new Map();
customSubjects.set('welcome', {
'en': 'Welcome to {{APP_NAME}}!',
'fr': 'Bienvenue sur {{APP_NAME}} !'
});
const mailer = new EmailClient({
subjects: customSubjects,
templatesPath: './templates'
});
# Set custom template directory
MAILER_TEMPLATES_PATH=./my-custom-templates
# or
EMAIL_TEMPLATES_PATH=./my-custom-templates
Complete Templates Guide - Detailed documentation on creating and customizing templates
git clone https://github.com/puparia/composa.git
cd composa
npm install
npm test
npm run example
composa/
├── src/
│ ├── index.js # Main exports
│ ├── email-client.js # EmailClient class
│ ├── template-engine.js # Template processing
│ └── default-subjects.js # Built-in subjects
├── templates/
│ ├── fr-FR/ # French templates
│ └── en-EN/ # English templates
├── examples/
│ └── basic-usage.js # Usage examples
├── README.md
└── package.json
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Puparia
FAQs
Compose beautiful multilingual emails with XHTML templates and Nodemailer
The npm package composa receives a total of 15 weekly downloads. As such, composa popularity was classified as not popular.
We found that composa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.