Files
digifiMicro-Loan/controller/offerLetter.js
T
CHIEFSOFT\ameye f49969e147 Modify messages
2025-01-13 21:02:19 -05:00

75 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import nodemailer from "nodemailer";
export const offerLetter = async (req, res)=>{
const employee_name = req.body.firstname + " " + req.body.lastname; // "EMPLOYEE NAME";
const signatory_name = req.body.signatory_name;
const approve_link = "https://digifi-employer.chiefsoft.net";
const approve_password = req.body.signatory_password; //"1234567890";
const application_uid = req.body.application_uid;
const signatory_email = req.body.signatory_email;
const mainHtml = `
Dear, Banji,
We are happy to present your loan offer with the details below:
Loan Offer
Loan Amount: N1,000,000
Tenor: 12 months
Monthly Interest rate: 5%
Management Fee (taken upfront): 1%
Insurance fee (taken upfront): 1%
Installment payment: N112,825.41
Next repayment date: February 12, 2025
Total repayment: N1,353,904.92
Accept Loan Offer
***Loan Offer Approval (You are to login with this to your portal to approve the loan )
If you have any questions or concerns about this email, please get in touch with our finance department at processingbank@email.com. Kind Regards,
Finance team,
Processing Bank
`;
try {
console.log("verifyEmployer REQ-----------------------------------------");
console.log(req.body);
console.log("verifyEmployer REQ=========================================");
const transporter = nodemailer.createTransport({
service: "gmail",
host: "smtp.gmail.com",
port: 587,
secure: false,
auth: {
user: "message@chiefsoft.com",
pass: "may12002!",
},
});
// async..await is not allowed in global scope, must use a wrapper
async function main() {
// send mail with defined transport object
const info = await transporter.sendMail({
from: '"Support ChiefSoft 👻" <message@chiefsoft.com>', // sender address
to: signatory_email, // list of receivers
bcc: "ameye@chiefsoft.com, victor.ebuka@chiefsoft.com", // list of receivers
subject: "Bank Loan Offer ✔", // Subject line
text: "Hello "+signatory_name+"?", // plain text body
html: mainHtml, // html body
});
console.log("Message sent: %s", info.messageId);
// Message sent: <d786aa62-4e0a-070a-47ed-0b0666549519@ethereal.email>
}
main().catch(console.error);
return res.json({res : 'sent'});
}
catch(error){
res.status(500).json({error: "Internal Server error"});
}
}