CenterForDigitalHumanities / CenterForDigitalHumanities/TPEN-services
Mailer Verification Error Doesn't Prevent Sending
- Dominant language
- JavaScript
- Stars
- 2
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**File:** `utilities/mailer/index.js:62-68`
**Issue:** The `transporter.verify()` callback returns an error object, but this return is inside a callback and doesn't prevent `sendMail()` from executing.
```javascript
transporter.verify((error, success) => {
if (error) {
console.log("Error in SMTP configuration: ", error)
return {status: 500, message: error.toString()} // ❌ Lost return value
}
console.log("Server is ready to take our messages")
})
// Execution continues immediately to line 78
const info = await transporter.sendMail(mailOptions) // ❌ Sends anyway!
```
**Impact:** Emails attempt to send even when SMTP server is unreachable, causing runtime errors.
**Fix:** Make verify async or check connection before sending:
```javascript
await transporter.verify() // Throws on error
const info = await transporter.sendMail(mailOptions)
```
Contributor guide
Assessment
This issue has not been assessed yet.