unoffical wafrn mirror
wafrn.net
atproto
social-network
activitypub
1import nodemailer from 'nodemailer'
2import { completeEnvironment } from './backendOptions.js'
3import SMTPTransport from 'nodemailer/lib/smtp-transport/index.js'
4import { logger } from './logger.js'
5const transporter = nodemailer.createTransport(completeEnvironment.emailConfig)
6
7export default async function sendEmail(options: {
8 email: string
9 subject: string
10 body: string
11}): Promise<SMTPTransport.SentMessageInfo | undefined> {
12 let res = undefined
13 try {
14 res = await transporter.sendMail({
15 from: completeEnvironment.emailConfig.auth.from,
16 to: options.email,
17 subject: options.subject,
18 html: options.body
19 })
20 } catch (error) {
21 logger.info({
22 message: `Error sending email`,
23 error: error
24 })
25 }
26 return res
27}