No crashes when mail fails

This commit is contained in:
Keith Irwin 2023-03-17 21:48:21 -06:00
parent 01591adbc8
commit 753535648e
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
4 changed files with 8 additions and 8 deletions

View File

@ -23,12 +23,12 @@ module.exports = async (req, res) => {
subject: 'Bug found!',
text: req.body['msg'],
})
console.log(`Sent email ${mail_res.messageId}`)
return res.sendStatus(200)
} catch (err) {
console.error(err)
return res.sendStatus(500)
}
console.log(`Sent email ${mail_res.messageId}`)
return res.sendStatus(200)
// hcaptcha failed
} else {

View File

@ -32,12 +32,12 @@ module.exports = async (req, res) => {
subject: req.body['subj'],
text: req.body['msg'],
})
console.log(`Sent email ${mail_res.messageId}`)
return res.sendStatus(200)
} catch (err) {
console.error(err)
return res.sendStatus(500)
}
console.log(`Sent email ${mail_res.messageId}`)
return res.sendStatus(200)
// hcaptcha failed
} else {

View File

@ -15,6 +15,6 @@ module.exports = async (order) => {
subject: `Order ${order.id} for ${formatUSD(order.total)} has been processed`,
text: `Dear ${order.contact.name},\n\nThank you for your payment. We will ship your order as soon as possible and send the tracking info to this email address. For now, keep this copy of your order details as proof of your payment. \n\n---\n\nITEMS: \n${customer_mail_items_string}\nTOTALS: \nSubtotal: ${formatUSD(order.subtotal)}\nTax: ${formatUSD(order.taxAmount)}\nShipping: ${formatUSD(order.shipping.amount)}\nProcessing: ${formatUSD(order.processing)}\n\nCONTACT: \n${order.contact.name}\n${order.contact.phone}\n${order.contact.email}\n\nSHIPPING ADDRESS:\n${order.shipping.address.name}\n${order.shipping.address.addr1}${(order.shipping.address.addr2)?'\n'+order.shipping.address.addr2:''}\n${order.shipping.address.city}, ${order.shipping.address.state} ${order.shipping.address.zip}\n\n---\n\nFor questions, comments, or to cancel this order, reply to this email or call 719-936-7778 x1. \n\nThank you!\n\n`,
})
console.log(`Sent email ${customer_mail_res.messageId} to customer for order ${order.id}`)
} catch (err) { console.error(err) }
console.log(`Sent email ${customer_mail_res.messageId} to customer for order ${order.id}`)
}
}

View File

@ -14,6 +14,6 @@ module.exports = async (order) => {
subject: `Order for ${formatUSD(order.total)} processed`,
text: `Order ${order.id} needs ${order.items.length} items shipped: \n\n${sales_mail_items_string}\nSHIP TO:\n${order.shipping.address.name}\n${order.shipping.address.addr1}${(order.shipping.address.addr2)?'\n'+order.shipping.address.addr2:''}\n${order.shipping.address.city}, ${order.shipping.address.state} ${order.shipping.address.zip}\n\nCONTACT:\n${order.contact.name}\n${order.contact.phone}\n${order.contact.email}\n`,
})
console.log(`Sent email ${sales_mail_res.messageId} to sales team for order ${order.id}`)
} catch (err) { console.error(err) }
console.log(`Sent email ${sales_mail_res.messageId} to sales team for order ${order.id}`)
}
}