Index page almost OK. Now work on variant page (main hall...)
[vchess.git] / utils / sendEmail.js.dist
diff --git a/utils/sendEmail.js.dist b/utils/sendEmail.js.dist
new file mode 100644 (file)
index 0000000..cad123e
--- /dev/null
@@ -0,0 +1,32 @@
+const nodemailer = require('nodemailer');
+
+module.exports = function(email, subject, content, cb)
+{
+  // create reusable transporter object using the default SMTP transport
+       const transporter = nodemailer.createTransport({
+               host: "smtp_host_address",
+               port: 465, //if secure; otherwise use 587
+               secure: true,
+               auth: {
+                       user: "user_name",
+                       pass: "user_password"
+               }
+       });
+
+       // setup email data with unicode symbols
+       const mailOptions = {
+               from: email, //note: some SMTP serves might forbid this
+               to: "contact_email",
+               subject: subject,
+               text: content,
+  };
+
+       // send mail with defined transport object
+       transporter.sendMail(mailOptions, (error, info) => {
+               if (!!error)
+                       return cb(error);
+    // Ignore info. Option:
+               //console.log('Message sent: %s', info.messageId);
+               return cb();
+  });
+};