0.5.21 • Published 8 months ago
@tomei/mailer v0.5.21
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.21
8 months ago
0.5.20
8 months ago
0.5.18
8 months ago
0.5.19
8 months ago
0.5.16
8 months ago
0.5.14
11 months ago
0.5.15
10 months ago
0.5.13
1 year ago
0.5.10
1 year ago
0.5.11
1 year ago
0.5.9
1 year ago
0.5.8
1 year ago
0.5.7
1 year ago
0.2.0
2 years ago
0.5.4
2 years ago
0.5.3
2 years ago
0.5.6
2 years ago
0.5.5
2 years ago
0.5.0
2 years ago
0.3.2
2 years ago
0.1.4
2 years ago
0.4.0
2 years ago
0.5.2
2 years ago
0.3.3
2 years ago
0.1.5
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago