CenterForDigitalHumanities / CenterForDigitalHumanities/TPEN-services

Mailer Verification Error Doesn't Prevent Sending

Open
#401 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.