
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@454creative/easy-email
Advanced tools
A framework-agnostic email service library for Node.js with observability and monitoring
A framework-agnostic email service library for Node.js with observability and monitoring capabilities. Supports SMTP, SendGrid, and AWS SES providers with comprehensive error handling, performance monitoring, and template rendering.
npm install @454creative/easy-email
import { EmailService, EmailProviderType } from '@454creative/easy-email';
// Configure with SMTP
const emailService = new EmailService({
type: EmailProviderType.SMTP,
config: {
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: 'your-email@gmail.com',
pass: 'your-password'
}
}
});
// Or configure with SendGrid
const sendGridService = new EmailService({
type: EmailProviderType.SENDGRID,
config: {
apiKey: 'your-sendgrid-api-key'
}
});
// Send email
const result = await emailService.sendEmail({
to: 'recipient@example.com',
subject: 'Hello from Easy Email!',
text: 'This is a test email',
from: 'sender@example.com'
});
if (result.success) {
console.log('Email sent successfully!');
} else {
console.error('Failed to send email:', result.error);
}
import { EmailService, EmailProviderType } from '@454creative/easy-email';
const emailService = new EmailService({
type: EmailProviderType.SENDGRID,
config: {
apiKey: 'your-sendgrid-api-key'
}
});
import { EmailService, EmailProviderType, EmailConfigBuilder } from '@454creative/easy-email';
// Method 1: Using EmailConfigBuilder (Recommended)
const config = new EmailConfigBuilder(EmailProviderType.SES)
.withSesConfig({
region: 'us-west-2',
// Credentials will be loaded from environment variables:
// AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
})
.withRetryAttempts(3)
.withTimeout(10000)
.build();
const emailService = new EmailService(config, { email: 'noreply@yourcompany.com' });
The library supports proper dependency injection with no singletons, making it perfect for multi-tenant applications:
import { EmailService, EmailProviderType, ObservabilityService } from '@454creative/easy-email';
// Create tenant-specific observability services
const tenant1Observability = new ObservabilityService({
enabled: true,
tenantId: 'tenant-1',
scope: 'tenant'
});
const tenant2Observability = new ObservabilityService({
enabled: true,
tenantId: 'tenant-2',
scope: 'tenant'
});
// Create isolated email services for each tenant
const tenant1Service = new EmailService(
{
type: EmailProviderType.SMTP,
config: { host: 'smtp.tenant1.com', port: 587, secure: false }
},
{ email: 'noreply@tenant1.com' },
tenant1Observability // Inject tenant-specific observability
);
const tenant2Service = new EmailService(
{
type: EmailProviderType.SENDGRID,
config: { apiKey: 'tenant2-api-key' }
},
{ email: 'noreply@tenant2.com' },
tenant2Observability // Inject tenant-specific observability
);
// Each tenant's metrics and events are completely isolated
await tenant1Service.sendEmail({ to: 'user1@example.com', subject: 'Hello Tenant 1' });
await tenant2Service.sendEmail({ to: 'user2@example.com', subject: 'Hello Tenant 2' });
// Get isolated metrics for each tenant
const tenant1Metrics = tenant1Observability.getMetrics();
const tenant2Metrics = tenant2Observability.getMetrics();
For convenience, you can also use factory methods:
import { ProviderFactory } from '@454creative/easy-email';
// Create services with factory methods
const emailService = ProviderFactory.createEmailService(
{ type: EmailProviderType.SMTP, config: smtpConfig },
{ email: 'noreply@company.com' },
ProviderFactory.createObservabilityService({ enabled: true, scope: 'production' })
);
import {
// Main services
EmailService,
ObservabilityService,
SesService,
// Enums and constants
EmailProviderType,
EMAIL_CONSTANTS,
OBSERVABILITY_CONSTANTS,
// Performance utilities
PerformanceMonitor,
trackPerformance,
// Version information
VERSION,
LIBRARY_INFO,
// Error classes
EmailServiceError,
ConfigurationError,
ProviderError,
ValidationError,
// Utility functions
validateEmail,
isValidEmail,
checkEmailTypos
} from '@454creative/easy-email';
The main service class for sending emails.
new EmailService(
providerConfig: EmailProviderConfig | SmtpConfig,
defaultFrom?: { email: string; name?: string },
observabilityConfig?: ObservabilityConfig
)
sendEmail(request: EmailRequest): Promise<EmailResponse> - Send an emailverifyConnection(): Promise<boolean> - Verify provider connectionsendPlainText(to, subject, text, options?): Promise<EmailResponse> - Send plain text emailsendHtml(to, subject, html, options?): Promise<EmailResponse> - Send HTML emailinterface EmailRequest {
to: string | string[];
subject: string;
text?: string;
html?: string;
from?: string;
cc?: string | string[];
bcc?: string | string[];
replyTo?: string;
attachments?: EmailRequestAttachment[];
headers?: Record<string, string>;
}
enum EmailProviderType {
SMTP = 'smtp',
SENDGRID = 'sendgrid',
SES = 'ses'
}
interface EmailResponse {
success: boolean;
messageId?: string;
error?: {
message: string;
code?: string;
provider?: string;
details?: any;
};
}
The library includes built-in observability features:
import { ObservabilityService } from '@454creative/easy-email';
const observability = ObservabilityService.getInstance({
enabled: true,
logLevel: 'info',
trackMetrics: true
});
// Get metrics
const metrics = observability.getMetrics();
console.log('Email metrics:', metrics);
Track performance with the built-in performance monitor:
import { PerformanceMonitor } from '@454creative/easy-email';
const monitor = PerformanceMonitor.getInstance({
enabled: true,
thresholdMs: 1000,
logSlowOperations: true
});
// Get performance summary
const summary = monitor.getSummary();
console.log('Performance summary:', summary);
The library provides comprehensive error handling:
import {
EmailServiceError,
ValidationError,
ProviderError
} from '@454creative/easy-email';
try {
const result = await emailService.sendEmail(request);
// Handle success
} catch (error) {
if (error instanceof ValidationError) {
console.error('Validation error:', error.message);
} else if (error instanceof ProviderError) {
console.error('Provider error:', error.message);
} else {
console.error('Unexpected error:', error);
}
}
See the examples/ directory for comprehensive examples:
For detailed documentation and guides, see the Documentation Directory.
# Run all tests
npm test
# Run unit tests
npm run test:unit
# Run integration tests
npm run test:integration
# Run with coverage
npm run test:coverage
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the ISC License - see the LICENSE file for details.
See CHANGELOG.md for a complete list of changes, version history, and migration guides.
Made with ❤️ by 454 Creative
FAQs
A framework-agnostic email service library for Node.js with observability and monitoring
We found that @454creative/easy-email demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.