Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^([^.]+)$ views/$1.ejs [NC,L] <----- This line was missing
- RewriteEngine On
- RewriteRule ^$ http://127.0.0.1:49555/ [P,L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ http://127.0.0.1:49555/$1 [P,L]
- DirectoryIndex views/index.ejs
- app.post('/send-email', (req,res) => {
- const output = `
- <p>You have a new contact request</p>
- <h3>Contact Details</h3>
- <ul>
- <li>Name: ${req.body.name}</li>
- <li>Email: ${req.body.email}</li>
- <li>Phone: ${req.body.phone}</li>
- </ul>
- <h3>Message</h3>
- <p>${req.body.message}</p>
- `;
- let transporter = nodemailer.createTransport({
- host: 'mail.digital-alchemy.solutions',
- port: 587,
- secure: false, // true for 465, false for other ports
- auth: {
- user: 'info@digital-alchemy.solutions', // generated ethereal user
- pass: '********' // generated ethereal password
- },
- tls: {
- rejectUnauthorized:false
- }
- });
- // setup email data with unicode symbols
- let mailOptions = {
- from: '"Digital Alchemy Contact Form" <wayne@digital-alchemy.solutions>', // sender address
- to: 'wayne@digital-alchemy.solutions, waynebruton@icloud.com', // list of receivers
- subject: 'Alchemy Contact Request', // Subject line
- text: 'Hello world?', // plain text body
- html: output // html body
- };
- // send mail with defined transport object
- transporter.sendMail(mailOptions, (error, info) => {
- if (error) {
- return console.log(error);
- req.flash("error", "There was an error! Please try again later");
- res.redirect("back");
- }
- console.log('Message sent: %s', info.messageId);
- // Preview only available when sending through an Ethereal account
- console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
- // res.sendStatus(200);
- req.flash("success", "Thank you " + req.body.name + ". Mail successfully sent! We will contact you shortly!");
- res.redirect("back");
- // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
- // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
- });
- });
Add Comment
Please, Sign In to add comment