@tadacafe/email
v1.0.3
Published
Multi-provider email service for web applications
Downloads
303
Maintainers
Readme
@tadacafe/email
Multi-provider email service with template management for web applications.
Features
- 📧 Multi-provider Support: Brevo and Resend email providers
- 🎨 Template System: HTML and text email templates
- ⚙️ Configuration-driven: Flexible environment-based setup
- 🔄 Fallback Strategy: Automatic provider fallback
- 🛡️ Type-safe: Full TypeScript support
- 🌐 Framework-agnostic: Works in any JavaScript environment
Installation
npm install @tadacafe/emailQuick Start
import { sendEmail, createEmailConfig } from '@tadacafe/email';
// Configure email service
const config = createEmailConfig({
providers: {
resend: {
apiKey: process.env.RESEND_API_KEY,
},
brevo: {
apiKey: process.env.BREVO_API_KEY,
},
},
from: {
email: '[email protected]',
name: 'Your Company',
},
to: {
email: '[email protected]',
name: 'Your Company',
},
});
// Send email
const success = await sendEmail(
{
name: 'John Doe',
email: '[email protected]',
company: 'Acme Corp',
message: 'Hello, I am interested in your services.',
},
config
);API Reference
Types
ContactFormData
interface ContactFormData {
name: string;
email: string;
company?: string;
message: string;
}EmailConfig
Configuration object for email service providers and settings.
Functions
sendEmail(formData, config)
Sends emails using the configured provider with automatic fallback.
createEmailConfig(options)
Creates a configuration object for the email service.
getBusinessEmailTemplate(formData, config?)
Generates business notification email template.
getConfirmationEmailTemplate(formData, config?)
Generates customer confirmation email template.
Configuration
The package supports multiple email providers with automatic fallback:
- Resend (primary)
- Brevo (fallback)
Environment Variables
RESEND_API_KEY=your_resend_api_key
BREVO_API_KEY=your_brevo_api_key
[email protected]
[email protected]License
MIT
