Guest User

Untitled

a guest
Apr 22nd, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. RewriteEngine On
  2. RewriteCond %{REQUEST_FILENAME} !-f
  3. RewriteRule ^([^.]+)$ views/$1.ejs [NC,L] <----- This line was missing
  4. RewriteEngine On
  5. RewriteRule ^$ http://127.0.0.1:49555/ [P,L]
  6. RewriteCond %{REQUEST_FILENAME} !-f
  7. RewriteCond %{REQUEST_FILENAME} !-d
  8. RewriteRule ^(.*)$ http://127.0.0.1:49555/$1 [P,L]
  9. DirectoryIndex views/index.ejs
  10.  
  11. app.post('/send-email', (req,res) => {
  12. const output = `
  13. <p>You have a new contact request</p>
  14. <h3>Contact Details</h3>
  15. <ul>
  16. <li>Name: ${req.body.name}</li>
  17. <li>Email: ${req.body.email}</li>
  18. <li>Phone: ${req.body.phone}</li>
  19. </ul>
  20. <h3>Message</h3>
  21. <p>${req.body.message}</p>
  22. `;
  23. let transporter = nodemailer.createTransport({
  24. host: 'mail.digital-alchemy.solutions',
  25. port: 587,
  26. secure: false, // true for 465, false for other ports
  27. auth: {
  28. user: 'info@digital-alchemy.solutions', // generated ethereal user
  29. pass: '********' // generated ethereal password
  30. },
  31. tls: {
  32. rejectUnauthorized:false
  33. }
  34. });
  35. // setup email data with unicode symbols
  36. let mailOptions = {
  37. from: '"Digital Alchemy Contact Form" <wayne@digital-alchemy.solutions>', // sender address
  38. to: 'wayne@digital-alchemy.solutions, waynebruton@icloud.com', // list of receivers
  39. subject: 'Alchemy Contact Request', // Subject line
  40. text: 'Hello world?', // plain text body
  41. html: output // html body
  42. };
  43. // send mail with defined transport object
  44. transporter.sendMail(mailOptions, (error, info) => {
  45. if (error) {
  46. return console.log(error);
  47. req.flash("error", "There was an error! Please try again later");
  48. res.redirect("back");
  49. }
  50. console.log('Message sent: %s', info.messageId);
  51. // Preview only available when sending through an Ethereal account
  52. console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
  53. // res.sendStatus(200);
  54. req.flash("success", "Thank you " + req.body.name + ". Mail successfully sent! We will contact you shortly!");
  55. res.redirect("back");
  56. // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
  57. // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
  58. });
  59. });
Add Comment
Please, Sign In to add comment