-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix of not being able to navigate after changing page
- Loading branch information
Manuel Neumayer
committed
Jun 25, 2020
1 parent
dae2c0a
commit 7dd59f5
Showing
4 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.vscode | ||
node_modules | ||
node_modules | ||
config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,53 @@ | ||
const express = require("express"); | ||
const nodemailer = require("nodemailer"); | ||
const bodyParser = require("body-parser"); | ||
const secrets = require("../config/secrets.json"); | ||
|
||
const router = express.Router(); | ||
|
||
router.use(express.static('public')); | ||
router.use(bodyParser.urlencoded({ extended: true })) | ||
|
||
router.get("/", (req, res) => res.render("index.ejs")); | ||
|
||
router.get("/about", (req, res) => { | ||
res.render("about.ejs"); | ||
}) | ||
|
||
router.post("/contact", (req, res) => { | ||
async function main() { | ||
let transporter = nodemailer.createTransport({ | ||
host: 'smtp.googlemail.com', | ||
port: 465, | ||
secure: true, | ||
auth: { | ||
user: secrets.NODEMAILER_TRANSPORT_USER, | ||
pass: secrets.NODEMAILER_TRANSPORT_PASSWORD | ||
} | ||
}); | ||
|
||
// send mail with defined transport object | ||
let info = await transporter.sendMail({ | ||
from: req.body.email, | ||
to: secrets.NODEMAILER_TRANSPORT_USER, // list of receivers | ||
subject: req.body.topic, // Subject line | ||
text: req.body.content, // plain text body | ||
html: | ||
` | ||
<h1>(Nodemailer) New Contact Request | ||
<p><strong>From:</strong> ${req.body.email}</p> | ||
<p><strong>Name:</strong> ${req.body.name}</h3> | ||
<p><strong>Subject:</strong> ${req.body.topic}</p> | ||
<p><strong>Message:</strong> ${req.body.content}</p> | ||
` // html body | ||
}); | ||
|
||
console.log('Message sent: %s', info.messageId); | ||
console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info)); | ||
} | ||
|
||
main().catch(console.error); | ||
res.redirect("/"); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters