Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // delete competition form
- router.get('/dashboard/users/forms/competition-form/delete/:id', ensureAuthenticated, (req, res, next) => {
- CompetitionForm.findByIdAndRemove(req.params.id, function(err, competition, user){
- req.flash('success_msg', `The competition form removed successfully!`);
- res.redirect('/dashboard');
- const output = `
- <h3>Competition Form Deletion</h3>
- <p>Hello ${user.schoolName},<p>
- <p>We are emailing you to make you aware that your competition form has been deleted from our records!<p>
- <br>
- <p>- POL – Puerto Rico</>
- `;
- nodemailer.createTestAccount((err, account) => {
- // create reusable transporter object using the default SMTP transport
- if (process.env.NODE_ENV === 'production') {
- transporter = nodemailer.createTransport({
- host: "smtp.sendgrid.net",
- port: 587,
- auth: {
- user: process.env.SENDGRID_USERNAME,
- pass: process.env.SENDGRID_PASSWORD,
- }
- });
- } else {
- transporter = nodemailer.createTransport({
- host: "smtp.ethereal.email",
- port: 587,
- auth: {
- user: 'qkkvnabtziufbksa@ethereal.email',
- pass: 'A4W9HF2WbhAav263VM',
- }
- });
- }
- // setup email data with unicode symbols
- let mailOptions = {
- from: process.env.GLOBAL_EMAIL || 'ben@benbagley.co.uk', // sender address
- to: `${user.email}`, // list of receivers
- subject: 'Competition Form Deletion | Poetry Out Loud', // Subject line
- html: output // html body
- };
- // send mail with defined transport object
- transporter.sendMail(mailOptions, (error, info) => {
- if (error) {
- return console.log(error);
- }
- console.log('Message sent: %s', info.messageId);
- console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
- });
- });
- });
- });
Add Comment
Please, Sign In to add comment