redwoodiloilo-mailer
v1.0.2
Published
A simple TypeScript email sender package using nodemailer
Maintainers
Readme
redwoodiloilo-mailer
A simple TypeScript email sender package using nodemailer.
Installation
npm install redwoodiloilo-mailerBasic Usage
Using Auth and EmailService
import { Mailer, Auth, EmailService, EmailOptions } from "redwoodiloilo-mailer";
// Configure authentication
const auth: Auth = {
user: "[email protected]",
pass: "your-app-password",
};
// Optional email service configuration
const emailService: EmailService = {
service: "gmail",
host: "smtp.gmail.com",
secure: false,
};
// Create mailer instance
const mailer = new Mailer(auth, emailService);
// Send email
const emailOptions: EmailOptions = {
from: "[email protected]",
to: "[email protected]",
subject: "Test Email",
text: "This is a test email",
html: "<h1>Test Email</h1><p>This is a test email</p>",
};
await mailer.sendEmail(emailOptions);Using Auth Only (Gmail defaults)
import { Mailer, Auth, EmailOptions } from "redwoodiloilo-mailer";
const auth: Auth = {
user: "[email protected]",
pass: "your-app-password",
};
const mailer = new Mailer(auth);API Reference
Mailer
Constructor
constructor(auth: Auth, emailService?: EmailService)Types
interface Auth {
user: string;
pass: string;
}
interface EmailService {
service?: string;
host?: string;
secure?: boolean;
}
interface EmailOptions {
from: string;
to: string | string[];
subject: string;
text?: string;
html?: string;
}Methods
sendEmail(options: EmailOptions): Promise<boolean>verifyConnection(): Promise<boolean>getLastMessage(): Promise<any>
