forked from YURAresearch/YURAResearchDatabase
-
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.
Merge pull request #4 from YURAresearch/master
catch up
- Loading branch information
Showing
13 changed files
with
92 additions
and
126 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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 was deleted.
Oops, something went wrong.
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,50 +1,43 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
const nodemailer = require('nodemailer'); | ||
var config = require('../bin/config'); | ||
|
||
var Mailgun = require('mailgun').Mailgun; | ||
|
||
var mg = new Mailgun(config.mailgun_key); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
res.render('feedback', { | ||
title: 'Feedback' | ||
}); | ||
res.render('feedback', { | ||
title: 'Feedback' | ||
}); | ||
}); | ||
|
||
router.post('/', function(req, res) { | ||
if (req.query.submit) { | ||
let transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: '[email protected]', | ||
pass: 'undergradresearch' | ||
} | ||
}); | ||
|
||
// setup email data with unicode symbols | ||
var mailOptions = { | ||
from:'[email protected]', // sender address | ||
to: '[email protected]', // list of receivers | ||
replyTo: req.body.email, | ||
subject: '[RDB Feedback] '+req.body.subject, // Subject line | ||
html: '<h3>Name</h3><p>' + req.body.name + '</p><h1>Message</h1><p>' + req.body.message+ '</p>', // plain text body | ||
}; | ||
if(req.body.email){ | ||
var sender = (req.body.name + ' <' + req.body.email + '>'); | ||
} else{ | ||
var sender = ('Anonymous User <[email protected]>'); | ||
} | ||
var subject = (req.body.subject || 'RDB Feedback'); | ||
var message = (req.body.message); | ||
|
||
// send mail with defined transport object | ||
transporter.sendMail(mailOptions, (error, info) => { | ||
if (error) { | ||
res.render('feedback', { | ||
title: 'Feedback', | ||
message: 'Error: Please try again, or email us at [email protected].', | ||
}); | ||
} else { | ||
res.render('feedback', { | ||
title: 'Feedback', | ||
message: 'Your message has been sent! Thank you for your feedback.', | ||
}); | ||
} | ||
mg.sendText(sender, '[email protected]', subject, message, | ||
function(err) { | ||
if (err) { | ||
console.log(err); | ||
res.render('feedback', { | ||
title: 'Feedback', | ||
message: 'Error: Please try again, or email us at [email protected].', | ||
}); | ||
} else { | ||
res.render('feedback', { | ||
title: 'Feedback', | ||
message: 'Your message has been sent! Thank you for your feedback.', | ||
}); | ||
} else { | ||
res.send('Error'); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
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
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
Oops, something went wrong.