🧑💻 (emails) Add decent emails management
Use mjml-react to generate emails. Put all emails in a independent package.
This commit is contained in:
20
packages/emails/sendEmail.ts
Normal file
20
packages/emails/sendEmail.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { createTransport, SendMailOptions } from 'nodemailer'
|
||||
import { env } from 'utils'
|
||||
|
||||
export const sendEmail = (
|
||||
props: Pick<SendMailOptions, 'to' | 'html' | 'subject'>
|
||||
) => {
|
||||
const transporter = createTransport({
|
||||
host: process.env.SMTP_HOST,
|
||||
port: Number(process.env.SMTP_PORT),
|
||||
auth: {
|
||||
user: process.env.SMTP_USERNAME,
|
||||
pass: process.env.SMTP_PASSWORD,
|
||||
},
|
||||
})
|
||||
|
||||
return transporter.sendMail({
|
||||
from: process.env.SMTP_FROM ?? env('SMTP_FROM'),
|
||||
...props,
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user