Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by tiffanyraill on 2017-03-28.
- */
- var express=require('express');
- var nodemailer = require("nodemailer");
- var router = express.Router();
- /*
- Here we are configuring our SMTP Server details.
- STMP is mail server which is responsible for sending and recieving email.
- */
- var smtpTransport = nodemailer.createTransport({
- service: "gmail",
- host: "smtp.gmail.com",
- auth: {
- user: ' ',
- pass: ' '
- }
- });
- /*------------------SMTP Over-----------------------------*/
- /*------------------Routing Started ------------------------*/
- router.get('/',function(req,res){
- res.sendfile('contactMe.ejs');
- });
- router.post('/send',function(req,res){
- console.log(req.body)
- var mailOptions={
- subject: req.body.name,
- to: '<miss tiffanys email address>',
- text: req.body.comments
- };
- console.log(mailOptions);
- smtpTransport.sendMail(mailOptions, function(error, response){
- if(error){
- console.log(error);
- res.end("error");
- }else{
- console.log("Message sent: " + response.message);
- res.end("sent");
- }
- });
- });
- module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement