Configure email sender as object instead

This commit is contained in:
arttu
2024-08-06 12:45:43 +03:00
parent 4def880488
commit 5e35a5a65e
+4 -1
View File
@@ -39,10 +39,13 @@ router.post(
return res.status(400).json({ message: 'Emails already sent in last minute.' })
}
emailSent = new Date()
if (!CONTACT_FROM_NAME || !CONTACT_FROM_EMAIL || !CONTACT_SMTP_HOST || !CONTACT_SMTP_PORT) {
return res.status(500).json({ message: 'Server is missing configurations for sending emails.' })
}
logger.info(`Sending ${recipients.length} emails...`)
for (const recipient of recipients) {
await transport.sendMail({
from: `"${CONTACT_FROM_NAME}" <${CONTACT_FROM_EMAIL}>`,
from: { name: CONTACT_FROM_NAME, address: CONTACT_FROM_EMAIL },
to: recipient,
subject: title,
text: message,