temu-labels-crawler/email-utils.js

43 lines
1.1 KiB
JavaScript

const AWS = require("aws-sdk");
const nodemailer = require("nodemailer");
const utils = require("./utils");
const SES_CONFIG = {
accessKeyId: "AKIAWCDCR7WSPJMY7OUU",
secretAccessKey: "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",
region: "us-east-1",
};
// SES object
const AWS_SES = new AWS.SES(SES_CONFIG);
// Create an Amazon SES transporter
const transporter = nodemailer.createTransport({
SES: AWS_SES,
});
// send email using transporter send to multiple tos
const notify = (subject, body) => {
// params
let recipients = ["saif.haq@utopia.pk", "huzaifa.jiwani@utopia.pk"];
let emailSubject = `Utopia Deals Temu FBU ${subject} Job`;
let emailBody = `<p>${body}</p>`;
const mailOptions = {
from: `uRobot@utopiadeals.com`,
to: recipients,
subject: emailSubject,
html: emailBody,
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.error("Error sending email:", error);
} else {
console.info("Email sent successfully:", info.response);
}
});
};
//export send email function
exports.notify = notify;