From e5bd16f67d2f594c758dd9cc63b65b2c2e2b92cb Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Thu, 25 Nov 2021 10:47:37 -0700 Subject: [PATCH] Got emails working --- index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 73a1287..8956c3c 100644 --- a/index.js +++ b/index.js @@ -3,23 +3,22 @@ require('dotenv').config() const express = require('express') const app = express() -const bodyParser = require('body-parser') const {verify} = require('hcaptcha') +console.log(`Connecting to ${process.env.MAIL_SERVER} as ${process.env.MAIL_USER} ${process.env.MAIL_PASS}`) const mailer = require('nodemailer').createTransport({ host: process.env.MAIL_SERVER, port: 587, - secure: false, // STARTTLS LATER auth: { user: process.env.MAIL_USER, pass: process.env.MAIL_PASS, }, + tls: { + rejectUnauthorized: false, + }, }) -//app.use(express.json()) - -app.use(bodyParser.json()) - +app.use(express.json()) app.post('/', async (req, res) => { // Check token @@ -41,9 +40,10 @@ app.post('/', async (req, res) => { // Send email let mail_res; try { - console.log(`Sending email from ${from}...`) + console.log(`Sending email from ${from} to ${process.env.MAIL_TO}...`) mail_res = await mailer.sendMail({ - from: from, + from: 'www.ki9.us/contact ', + replyTo: from, to: process.env.MAIL_TO, subject: req.body['subj'], text: req.body['msg'],