1 const nodemailer = require('nodemailer');
3 const contact = "your_contact_email";
5 const send = function(from, to, subject, body, cb)
7 // Create reusable transporter object using the default SMTP transport
8 const transporter = nodemailer.createTransport({
9 host: "smtp_host_address",
10 port: 465, //if secure; otherwise use 587
18 // Setup email data with unicode symbols
20 from: from, //note: some SMTP serves might forbid this
26 // Avoid the actual sending in development mode
27 const env = process.env.NODE_ENV || 'development';
28 if ('development' === env)
30 console.log("New mail: from " + from + " / to " + to);
31 console.log("Subject: " + subject);
32 let msgText = body.split('\\n');
33 msgText.forEach(msg => { console.log(msg); });
37 // Send mail with the defined transport object
38 transporter.sendMail(mailOptions, (error, info) => {
41 // Ignore info. Option:
42 //console.log('Message sent: %s', info.messageId);