@efobi/mailer
v5.0.0
Published
A TypeScript SDK for Emails
Downloads
17
Maintainers
Readme
Mail Efobi Dev
This project is a monorepo containing a mailer service and a typesafe client.
Project Structure
apps/mailer: The mailer service application.packages/typesafe-client: The typesafe client for the mailer service.
Getting Started
Installation
To install the dependencies for the entire project, run the following command in the root directory:
bun installRunning the Mailer Service
To run the mailer service, run the following command in the root directory:
bun run --cwd apps/mailer startThe mailer service will be available at http://localhost:3000.
Using the Typesafe Client
To use the typesafe client, you can import it in your project like this:
import { createClient } from '@mail-efobi/typesafe-client';
const client = createClient('http://localhost:3000');
const emailData = {
smtpConfig: {
host: 'smtp.example.com',
port: 587,
secure: false,
auth: {
user: '[email protected]',
pass: 'password',
},
},
from: '[email protected]',
to: '[email protected]',
subject: 'Test Email',
text: 'This is a test email.',
};
client.sendEmail(emailData)
.then((response) => {
console.log('Email sent successfully:', response);
})
.catch((error) => {
console.error('Failed to send email:', error);
});