node.jsexpresssendmailnodemailermailer

How can I use node-sendmail to send emails? This package crashed the server


I'm using the node-Sendmail npm package in my express JS app, which is like the MVC structure. I have some weird errors, like

node_modules\sendmail\sendmail.js:291
    if (mail.to) {
             ^
TypeError: Cannot read properties of undefined (reading 'to')

enter image description here

Please see the image above. I tried to send the email when the login route was requested, but it sent the email after the server crashed, and this error showed. I checked their official GitHub and asked a question, but no one replied. Have you ever used a node-Sendmail package?

I checked to see if there were any errors in the node module package and code, and here is a screenshot.

enter image description here

I called the Sendmail with import module :

enter image description here


Solution

  • You're calling sendmail with no configuration on line 47, that is throwing your error