Created
October 3, 2022 03:46
-
-
Save ancyrweb/757262beeb2dd77df1746604be3ddfc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import * as nodemailer from 'nodemailer'; | |
import Mail from 'nodemailer/lib/mailer'; | |
export type SendEmailData = { | |
subject: string; | |
from: string; | |
to: string; | |
body: string; | |
}; | |
@Injectable() | |
export class EmailService { | |
private transport: Mail; | |
constructor() { | |
this.transport = nodemailer.createTransport({ | |
host: 'localhost', | |
port: 7002, | |
}); | |
} | |
async send(data: SendEmailData) { | |
return this.transport.sendMail({ | |
from: data.from, | |
to: data.to, | |
subject: data.subject, | |
html: data.body, | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment