@cabysis/mail-man
v1.0.3
Published
Mail-Man sender package is a TypeScript library for sending emails easily using SMTP created by CabySis.
Downloads
3
Readme
Email Sender Package
Mail-Man sender package is a TypeScript library for sending emails easily using SMTP created by CabySis.
Installation
You can install the lastest version as:
npm install @cabysis/mail-man
Usage
You can use this library after installation as this example:
import { sendMail, SendMailOptions, Providers, FileMeta } from '@cabysis/mail-man'; // Import necessary modules
// Define file metadata
const filesMeta: FileMeta[] = [
FileMeta.create({ filePath: "path/file.txt" }), // Create file meta by file stored on path
FileMeta.create({
// Create file meta by buffer and file name
buffer: Buffer.from("file buffer example"),
fileName: "file.txt",
}),
];
// Define email options
const sendMailOptions: SendMailOptions = {
subject: 'This is a subject', // Define email subject
message: 'This is email body message.', // Define email body
recipients: ['[email protected]'], // Define the email receivers list
filesMeta, // Include files metadata
provider: Providers.YourProviderName, // Specify the email provider
apiKey: 'your_api_key', // Specify the API key
};
// Send the email
sendMail(sendMailOptions)
.then(() => {
console.log('Email sent successfully.');
})
.catch((error) => {
console.error('Error sending email:', error);
});