Contact form build with Bootstrap and Nodemailer
- Install the dependencies and start the server.
$ git clone https://github.com/rezkyfm/nodejs-contact-form.git
$ cd nodejs-contact-form
$ npm install && npm start
- Open in browser
http://localhost:3000
Open config.js
/*
config.js
*/
module.exports = {
// Theme
theme: "lightBlue",
// Email notifier account (sender)
host: "smtp.mailtrap.io", // Sender email smtp
port: "465", // Sender email port
user: "username", // Sender email username
pass: "password", // Sender email password
// Your email to receive notification (receiver)
from: '"Contact Me" <[email protected]>', // Sender email address
to: '[email protected]', // Your email address
subject: 'Contact Us', // Subject
};
- Setup app password for gmail
- Open app.js and change
let transporter = nodemailer.createTransport({
host: config.host,
port: config.port,
secure: false,
auth: {
user: config.user,
pass: config.pass
},
tls:{
rejectUnauthorized:false
}
});
- replace to
let transporter = nodemailer.createTransport(
`smtps://${config.user}:${config.pass}@smtp.gmail.com`
);