Got emails working
parent
74635c17c8
commit
e5bd16f67d
16
index.js
16
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 <contact@ki9.us>',
|
||||
replyTo: from,
|
||||
to: process.env.MAIL_TO,
|
||||
subject: req.body['subj'],
|
||||
text: req.body['msg'],
|
||||
|
|
Loading…
Reference in New Issue