Send emails with different contexts using beautiful templates for common scenarios such as email confirmation and email recovery
npm install simple-sendmailThe app is still in alpha, so it may not work as expected. If you find any bugs or has an suggestion, please report them in the issues section.
The Simple Sendmail library provides a simple way to send emails using Node.js. It allows you to set up email configurations, create email messages, and send them using SMTP.
Installation
You can install Simple Sendmail using npm:
``
npm install simple-sendmail
`
``
import simpleSend, {Message, Config} from "simple-sendmail";
import Template, {ConfirmEmail} from 'simple-sendmail/dist/templates/template';
const template:Template = new Template();
`Configuring Email Options
Each template (HTML) has its own options. For the 'confirmEmail' template, there are only two options, with the title being optional.
`
const confirmEmailOptions: ConfirmEmail = {
title: 'Please confirm your e-mail', // optional
confirmationCode: 999999 // mandatory
};`
Configuring Email Settings
This tool uses nodemailer for sending emails, so you need to configure it accordingly.
`
// Node mailer configuration
const config: Config = {
host: "your_host.com",
port: 999,
auth: {
user: 'your_email@example.com',
pass: 'your_password'
}
};`Creating the Email Message
`
const message: Message = {
from: 'your_email@example.com', // mandatory
to: 'to@example.com', // mandatory
subject: "", // optional
html: template.confirmEmail(confirmEmailOptions) // choose the template and its options here
};
`$3
Create an instance of the simpleSend class using the configured email settings. Then, use the send method to send the email message
`
const sender = new simpleSend(config);
sender.send(message);
``