0.5.21 • Published 1 year 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/maileron your projectEnsure you have setup the environment from
.sampledotenvin your project.envfile
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
1 year ago
0.5.20
1 year ago
0.5.18
1 year ago
0.5.19
1 year ago
0.5.16
1 year ago
0.5.14
1 year ago
0.5.15
1 year ago
0.5.13
2 years ago
0.5.10
2 years ago
0.5.11
2 years ago
0.5.9
2 years ago
0.5.8
2 years ago
0.5.7
2 years ago
0.2.0
3 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
3 years ago
0.1.4
3 years ago
0.4.0
3 years ago
0.5.2
2 years ago
0.3.3
3 years ago
0.1.5
3 years ago
0.1.3
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago
0.0.10
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago