
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
emailer-sdk
Advanced tools
The official Node.js SDK for Emailer - The modern email API for developers.
npm install emailer-sdk
# or
yarn add emailer-sdk
# or
pnpm add emailer-sdk
import { Emailer } from 'emailer-sdk';
// or
const { Emailer } = require('emailer-sdk');
const emailer = new Emailer('your-api-key');
// Send your first email
const result = await emailer.emails.send({
from: 'onboarding@yourdomain.com',
to: 'user@gmail.com',
subject: 'Hello World',
html: '<strong>It works!</strong>',
text: 'It works!'
});
console.log(result);
// { id: '5e858953-7b3f-4b47-a0f4-3c1e5d8ec041', ... }
const emailer = new Emailer('your-api-key', {
baseUrl: 'http://localhost:3000/api/v1', // Default for local development
timeout: 30000, // 30 seconds
retries: 3 // Number of retries for failed requests
});
await emailer.emails.send({
from: 'team@yourdomain.com',
to: 'user@example.com',
subject: 'Welcome!',
html: '<p>Welcome to our service!</p>',
text: 'Welcome to our service!'
});
await emailer.emails.send({
from: 'team@yourdomain.com',
to: [
'user1@example.com',
{ email: 'user2@example.com', name: 'John Doe' }
],
cc: 'manager@yourdomain.com',
bcc: ['admin1@yourdomain.com', 'admin2@yourdomain.com'],
subject: 'Team Update',
html: '<p>Here is our weekly update...</p>'
});
import fs from 'fs';
await emailer.emails.sendWithAttachments({
from: 'billing@yourdomain.com',
to: 'customer@example.com',
subject: 'Your Invoice',
html: '<p>Please find your invoice attached.</p>',
attachments: [
{
filename: 'invoice.pdf',
content: fs.readFileSync('./invoice.pdf')
},
{
filename: 'logo.png',
content: fs.readFileSync('./logo.png'),
disposition: 'inline',
contentId: 'logo'
}
]
});
await emailer.emails.send({
from: 'noreply@yourdomain.com',
to: 'user@example.com',
templateId: 'welcome-email',
templateData: {
name: 'John Doe',
company: 'Acme Corp',
activationUrl: 'https://app.yourdomain.com/activate'
}
});
await emailer.emails.send({
from: 'reminders@yourdomain.com',
to: 'user@example.com',
subject: 'Reminder: Meeting Tomorrow',
html: '<p>Don\'t forget about our meeting!</p>',
scheduledAt: new Date('2024-12-25 09:00:00')
});
const emails = [
{
from: 'newsletter@yourdomain.com',
to: 'subscriber1@example.com',
subject: 'Newsletter #1',
html: '<p>Content...</p>'
},
{
from: 'newsletter@yourdomain.com',
to: 'subscriber2@example.com',
subject: 'Newsletter #1',
html: '<p>Content...</p>'
}
];
const results = await emailer.emails.sendBatch(emails);
// Enable tracking
await emailer.emails.send({
from: 'marketing@yourdomain.com',
to: 'lead@example.com',
subject: 'Special Offer',
html: '<p>Click <a href="https://example.com">here</a> for 50% off!</p>',
trackOpens: true,
trackClicks: true
});
// Get tracking events
const events = await emailer.emails.events('email-id');
console.log(events);
// [
// { type: 'sent', timestamp: '2024-01-01T10:00:00Z' },
// { type: 'delivered', timestamp: '2024-01-01T10:00:05Z' },
// { type: 'opened', timestamp: '2024-01-01T10:30:00Z' },
// { type: 'clicked', timestamp: '2024-01-01T10:31:00Z', data: { url: 'https://example.com' } }
// ]
const emails = await emailer.emails.list({
page: 1,
perPage: 50,
status: 'sent',
tag: 'marketing'
});
const email = await emailer.emails.get('email-id');
console.log(email);
// {
// id: 'email-id',
// from: 'team@yourdomain.com',
// to: ['user@example.com'],
// subject: 'Hello',
// status: 'delivered',
// events: [...]
// }
const result = await emailer.emails.resend('email-id');
await emailer.emails.cancel('email-id');
const validation = await emailer.emails.validate('user@example.com');
console.log(validation);
// {
// valid: true,
// syntax: true,
// dns: true,
// mx: true,
// disposable: false,
// role: false,
// deliverable: true,
// free: false,
// score: 95, // Deliverability score (0-100)
// reason: null, // Reason if invalid
// suggestion: null // Typo suggestion
// }
// Check before sending
if (validation.valid && validation.score > 50) {
await emailer.emails.send({
to: 'user@example.com',
subject: 'Hello',
html: '<p>Email validated!</p>'
});
}
import { SuppressionType } from 'emailer-sdk';
const check = await emailer.suppression.check('bounced@example.com');
if (check.suppressed) {
console.log(`Email suppressed: ${check.reason}`);
// Don't send to this email
}
// Add unsubscribed email
await emailer.suppression.add({
email: 'unsubscribe@example.com',
type: SuppressionType.UNSUBSCRIBE,
reason: 'User clicked unsubscribe link'
});
// Add manual suppression
await emailer.suppression.add({
email: 'donotcontact@example.com',
type: SuppressionType.MANUAL,
reason: 'Customer requested removal'
});
const stats = await emailer.suppression.getBounceStats(30); // Last 30 days
console.log(stats);
// {
// totalBounces: 150,
// hardBounces: 100,
// softBounces: 30,
// complaints: 20,
// bounceRate: 2.5, // Percentage
// period: '30 days'
// }
const list = await emailer.suppression.list({
type: SuppressionType.BOUNCE,
page: 1,
limit: 50
});
console.log(`Total suppressed: ${list.pagination.total}`);
list.data.forEach(item => {
console.log(`${item.email} - ${item.type}: ${item.reason}`);
});
await emailer.suppression.remove('reactivated@example.com');
try {
await emailer.emails.send({
from: 'team@yourdomain.com',
to: 'invalid-email',
subject: 'Test',
html: '<p>Test</p>'
});
} catch (error) {
console.error('Error:', error.message);
console.error('Status:', error.statusCode);
console.error('Details:', error.details);
}
The SDK is written in TypeScript and provides full type definitions:
import { Emailer, EmailOptions, SendEmailResponse } from 'emailer-sdk';
const emailer = new Emailer('your-api-key');
const options: EmailOptions = {
from: 'team@yourdomain.com',
to: 'user@example.com',
subject: 'Hello',
html: '<p>Hello World</p>'
};
const response: SendEmailResponse = await emailer.emails.send(options);
emailer.emails
send(options)
- Send a single emailsendBatch(emails)
- Send multiple emailssendWithAttachments(options)
- Send email with attachmentsget(id)
- Get email detailslist(params)
- List emailsresend(id)
- Resend an emailcancel(id)
- Cancel a scheduled emailvalidate(email)
- Validate email addressevents(emailId)
- Get email eventsemailer.domains
create(domain)
- Add a sending domainget(id)
- Get domain detailslist()
- List all domainsverify(id)
- Verify domain recordsdelete(id)
- Remove a domainemailer.templates
create(template)
- Create a templateget(id)
- Get template detailslist()
- List all templatesupdate(id, template)
- Update a templatedelete(id)
- Delete a templateemailer.webhooks
create(webhook)
- Create a webhookget(id)
- Get webhook detailslist()
- List all webhooksupdate(id, webhook)
- Update a webhookdelete(id)
- Delete a webhooktest(id)
- Test webhook endpointemailer.contacts
create(contact)
- Create a contactget(id)
- Get contact detailslist(params)
- List contactsupdate(id, contact)
- Update a contactdelete(id)
- Delete a contactunsubscribe(email)
- Unsubscribe a contactemailer.analytics
stats(query)
- Get email statisticsevents(query)
- Get email eventsdomains(query)
- Get domain statisticstags(query)
- Get tag statisticsMIT
FAQs
Official SDK for Emailer - The modern email API for developers
The npm package emailer-sdk receives a total of 132 weekly downloads. As such, emailer-sdk popularity was classified as not popular.
We found that emailer-sdk 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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socketβs AI scanner detected the supply chain attack and flagged the malware.
Security News
CISAβs 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.