nest-project/src/email/email.service.ts

20 lines
607 B
TypeScript
Raw Normal View History

2023-02-21 16:31:45 +08:00
import { Injectable } from '@nestjs/common'
import { MailerService } from '@nestjs-modules/mailer'
@Injectable()
export class EmailService {
constructor(private mailerService: MailerService) {}
async sendEmailTo(email: string) {
return this.mailerService.sendMail({
to: email, // list of receivers
subject: 'Testing Nest Mailermodule with template ✔',
template: 'index', // The `.pug` or `.hbs` extension is appended automatically.
context: {
// Data to be sent to template engine.
code: 'cf1a3f828287',
username: 'john doe',
},
})
}
}