2
0

🚸 (sendEmail) Better result logging

This commit is contained in:
Baptiste Arnaud
2022-10-04 08:17:05 +02:00
parent 471ffe8e21
commit 7ca97d4606
3 changed files with 53 additions and 2 deletions

View File

@ -112,7 +112,13 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
}
try {
const info = await transporter.sendMail(email)
await saveSuccessLog(resultId, 'Email successfully sent')
await saveSuccessLog(resultId, 'Email successfully sent', {
transportConfig: {
...transportConfig,
auth: { user: transportConfig.auth.user, pass: '******' },
},
email,
})
return res.status(200).send({
message: 'Email sent!',
info,
@ -120,7 +126,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
})
} catch (err) {
await saveErrorLog(resultId, 'Email not sent', {
transportConfig,
transportConfig: {
...transportConfig,
auth: { user: transportConfig.auth.user, pass: '******' },
},
email,
error: err,
})