Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
*.env
68 changes: 68 additions & 0 deletions backend/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//jshint esversion:6
const express = require("express");
const bodyParser = require("body-parser");
const nodemailer = require('nodemailer');

const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("../"))

app.get("/", (req, res) => {
res.redirect("index.html");
});

app.post("/", (req, res) => {
const name = req.body.name;
const email = req.body.email;
const message = req.body.message;

// YOUR EMAIL AUTHENTICATION REQUIRED
/* NOTE: REGULAR LOGIN PASSWORD WILL NOT WORK HERE IF TWO-FACTOR AUTHENTICATION IS ENABLED ON YOUR PROXY GOOGLE ACCOUNT.
THIS NEEDS AN APP-SPECIFIC PASSWORD
*/

/*
To generate your App-Specific Password follow these instructions:
1. Follow this link - https://myaccount.google.com/u/0/security?hl=en
Make sure you are on the proxy google account only.
2. Under the section named "Sigining in to Google" click on "App Passwords"
3. Verify it’s you by using the regular google account password
4. Select App -> Other (Custom name)
5. Click on "Generate"
6. Copy this generated password into the "pass" field down here
7. Voila! You are receiving messages via your proxy email when new users send any message
*/
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '<PROXY_EMAIL-ADDRESS>', // proxy email address
pass: '<PASSWORD>' // If 2FA is enabled for this google account, app-specific password to be generated following the instructions.
}
});

const mailData = {
from: 'yashkadulkar3@gmail.com', // proxy sender address
to: 'info@bedudo.com', // receive the message on your company email
subject: `Message from Bedudo user: ${name}, ${email}`,
text: `${message}`,
};

transporter.sendMail(mailData, function (err, info) {
if (err) {
// error possibly occurred due to failed login credentials on the provided Google Account
console.log(err);
res.send(err);
// res.redirect("../error.html");
}
else {
// success
console.log("Email Sent:", info);
res.redirect("/");
}
});
});




app.listen(process.env.PORT || 3000, () => console.log("Server running."));
2 changes: 1 addition & 1 deletion contacts.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2 class="fw-bold">How you can reach us</h2>
<div class="row d-flex justify-content-center">
<div class="col-md-6 col-xl-4">
<div>
<form class="p-3 p-xl-4" method="post">
<form class="p-3 p-xl-4" action="/" method="post">
<div class="mb-3"><input class="form-control" type="text" id="name-1" name="name" placeholder="Name"></div>
<div class="mb-3"><input class="form-control" type="email" id="email-1" name="email" placeholder="Email"></div>
<div class="mb-3"><textarea class="form-control" id="message-1" name="message" rows="6" placeholder="Message"></textarea></div>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ <h2 class="fw-bold">How you can reach us</h2>
<div class="row d-flex justify-content-center">
<div class="col-md-6 col-xl-4">
<div>
<form class="p-3 p-xl-4" method="post">
<form class="p-3 p-xl-4" action="/" method="post">
<div class="mb-3"><input class="form-control" type="text" id="name-1" name="name" placeholder="Name"></div>
<div class="mb-3"><input class="form-control" type="email" id="email-1" name="email" placeholder="Email"></div>
<div class="mb-3"><textarea class="form-control" id="message-1" name="message" rows="6" placeholder="Message"></textarea></div>
Expand Down