I'm trying to send an e-mail from a React/Node.js application. Currently, I'm trying to use emailjs module.
The code is the following:
const emailjs = require('emailjs')
sendEmail(email) {
var server = emailjs.server.connect({
user: "USERNAME",
password:"PASSWORD",
host: "HOST_URL",
ssl: false
});
server.send({
text: 'Message',
from: '"Sender" <mail@provider.com>',
to: email,
subject: "Some message subject"
},
function(err, message) {
console.log(err || message);
});
}
When this method is executed, I get the following error: net.Socket is not a constructor
.
How can I send an e-mail from a Node.JS application (using any NPM module, not necessarily emailjs)?
Update 1 (30.07.2017 09:12 MSK): Nodemailer doesn't work -- I get the error 09:11:03 web.1 | Module not found: Can't resolve 'dns' in 'C:\myproject\node_modules\nodemailer\lib\mailer'
.