forked from CSI-KJSCE/appointment_to_examiner
Emails (500 error resolved)
This commit is contained in:
@@ -1,64 +1,3 @@
|
|||||||
// // /routes/email.js
|
|
||||||
// const express = require("express");
|
|
||||||
// const nodemailer = require("nodemailer");
|
|
||||||
// const fs = require("fs");
|
|
||||||
// const router = express.Router();
|
|
||||||
|
|
||||||
// router.post("/", async (req, res) => {
|
|
||||||
// const { teacher, csvData, fileName, recipientEmail } = req.body;
|
|
||||||
|
|
||||||
// if (!teacher || !csvData || !fileName || !recipientEmail) {
|
|
||||||
// return res.status(400).json({ error: "Missing required fields" });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Save the CSV data to a temporary file
|
|
||||||
// const filePath = `./${fileName}`;
|
|
||||||
// fs.writeFileSync(filePath, csvData);
|
|
||||||
|
|
||||||
// // Configure Nodemailer transporter
|
|
||||||
// const transporter = nodemailer.createTransport({
|
|
||||||
// service: "gmail",
|
|
||||||
// auth: {
|
|
||||||
// user: "swdc.ate@gmail.com", // Replace with your email
|
|
||||||
// pass: "umlc hbkr dpga iywd", // Replace with your app-specific password or token
|
|
||||||
// },
|
|
||||||
// // tls: {
|
|
||||||
// // rejectUnauthorized: false, // Disable SSL verification
|
|
||||||
// // }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Email options
|
|
||||||
// const mailOptions = {
|
|
||||||
// from: "swdc.ate@gmail.com", // Replace with your email
|
|
||||||
// to: recipientEmail,
|
|
||||||
// subject: `Excel File for ${teacher}`,
|
|
||||||
// text: `Attached is the Excel file for ${teacher}.`,
|
|
||||||
// attachments: [
|
|
||||||
// {
|
|
||||||
// filename: fileName,
|
|
||||||
// path: filePath,
|
|
||||||
// contentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // MIME type for xlsx
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// };
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// // Send email
|
|
||||||
// await transporter.sendMail(mailOptions);
|
|
||||||
|
|
||||||
// // Delete the temporary file after sending the email
|
|
||||||
// fs.unlinkSync(filePath);
|
|
||||||
|
|
||||||
// res.status(200).json({ message: "Email sent successfully" });
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Error sending email:", error);
|
|
||||||
// res.status(500).json({ error: "Failed to send email" });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// module.exports = router;
|
|
||||||
|
|
||||||
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
@@ -92,6 +31,9 @@ router.post("/", upload.single("file"), async (req, res) => {
|
|||||||
user: "swdc.ate@gmail.com", // Replace with your email
|
user: "swdc.ate@gmail.com", // Replace with your email
|
||||||
pass: "umlc hbkr dpga iywd", // Replace with your app-specific password or token
|
pass: "umlc hbkr dpga iywd", // Replace with your app-specific password or token
|
||||||
},
|
},
|
||||||
|
connectionTimeout: 15000,
|
||||||
|
greetingTimeout: 15000,
|
||||||
|
socketTimeout: 15000,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Email options
|
// Email options
|
||||||
|
|||||||
Reference in New Issue
Block a user