0.5.11 • Published 14 days ago
@tomei/mailer v0.5.11
Tomei Mailer
Version Note
Current tomei mailer package version only supports nodemailer and nestjs/mailer
Getting Started
Execute
npm install @tomei/mailer
on your projectEnsure you have setup the environment from
.sampledotenv
in your project.env
file
Package Implementation
- Nodemailer
const nodemailer = require('nodemailer');
const { Mailer } = require('@tomei/mailer');
const mailConfig = {
host: process.env.SMTP_HOST,
port: Number(process.env.SMTP_PORT),
secure: Number(process.env.SMTP_PORT) === 465,
auth: {
user: process.env.EMAIL_SENDER,
pass: process.env.EMAIL_PASSWORD,
},
};
//Tomei Mailer Package Instatiation
const transporter = new Mailer(nodemailer, mailConfig);
async function sendMailFunc() {
await transporter.sendMail({
from: 'sender@mail.com',
to: 'recipient@mail.com',
subject: 'Test Email Subject',
text: 'Test Email Content',
});
}
- NestJS/Mailer
import { MailerService } from '@nestjs-modules/mailer'
import { ConfigService } from '@nestjs/config'
import { Mailer, MailerInterfaces } from '@tomei/mailer';
export class MailService {
private mailer: Mailer
constructor(
private mailerService: MailerService,
private configService: ConfigService
) {
const mailConfig: MailerInterfaces.MailConfig = {
host: this.configService.get('SMTP_HOST'),
port: Number(this.configService.get('SMTP_PORT')),
secure: Number(this.configService.get('SMTP_PORT')) === 465,
auth: {
user: this.configService.get('EMAIL_SENDER'),
pass: this.configService.get('EMAIL_PASSWORD'),
},
}
//Tomei Mailer Package Instatiation
this.mailer = new Mailer(mailerService, mailConfig)
}
async sendMailMethod() {
await this.mailer.sendMail({
to: 'recipient@mail.com',
subject: 'Test Subject',
template: <email_template_dir_path>,
context: {
System: 'My Project System'
}
})
}
}
0.5.10
14 days ago
0.5.11
14 days ago
0.5.9
2 months ago
0.5.8
4 months ago
0.5.7
4 months ago
0.2.0
10 months ago
0.5.4
7 months ago
0.5.3
8 months ago
0.5.6
6 months ago
0.5.5
7 months ago
0.5.0
9 months ago
0.3.2
10 months ago
0.1.4
10 months ago
0.4.0
10 months ago
0.5.2
9 months ago
0.3.3
10 months ago
0.1.5
10 months ago
0.1.3
11 months ago
0.1.2
11 months ago
0.1.1
11 months ago
0.1.0
11 months ago
0.0.10
11 months ago
0.0.9
11 months ago
0.0.8
11 months ago
0.0.7
11 months ago
0.0.6
11 months ago
0.0.5
11 months ago
0.0.4
11 months ago
0.0.3
11 months ago
0.0.2
11 months ago
0.0.1
11 months ago