Skip to content

Mailer Verification Error Doesn't Prevent Sending #401

@thehabes

Description

@thehabes

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.

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:

await transporter.verify() // Throws on error
const info = await transporter.sendMail(mailOptions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions