67 lines
1.7 KiB
JavaScript
67 lines
1.7 KiB
JavaScript
import nodeMailer from "nodemailer";
|
|
import { createTransport } from "nodemailer";
|
|
|
|
const transporter = createTransport({
|
|
host: process.env.SMPT_HOST,
|
|
port: process.env.SMPT_PORT,
|
|
// service: process.env.SMPT_SERVICE,
|
|
auth: {
|
|
user: process.env.SMPT_MAIL,
|
|
pass: process.env.SMPT_PASSWORD,
|
|
},
|
|
});
|
|
|
|
const sendEmail = async (options) => {
|
|
await transporter.sendMail(options, function (error, info) {
|
|
if (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
});
|
|
};
|
|
export default sendEmail;
|
|
|
|
// import sgMail from '@sendgrid/mail';
|
|
// sgMail.setApiKey(process.env.SENDGRID_API_KEY)
|
|
// // console.log(process.env.SENDGRID_API_KEY)
|
|
// const sendEmail = async (options) => {
|
|
// sgMail.send(options)
|
|
|
|
// }
|
|
// export default sendEmail
|
|
|
|
// from message bird send mail------------------------------------
|
|
// messageSender.js
|
|
// import messagebird from "messagebird";
|
|
|
|
// const apiKey = "7oOgyzfNuwBnqMc2oK6aGfczs";
|
|
// const messagebirdClient = messagebird(apiKey);
|
|
import { initClient } from "messagebird";
|
|
const messagebird = initClient("e7HGr3kMl6su4c79DKjNAwlLQ");
|
|
// e7HGr3kMl6su4c79DKjNAwlLQ
|
|
//7oOgyzfNuwBnqMc2oK6aGfczs
|
|
//11yKY8EbdFJpugJzaKyAH3YaK
|
|
|
|
|
|
export const sendOtp = async (recipient, message) => {
|
|
if (!recipient || !message) {
|
|
return;
|
|
}
|
|
const params = {
|
|
originator: "tavisa",
|
|
recipients: [recipient],
|
|
body: message,
|
|
};
|
|
|
|
|
|
messagebird.messages.create(params, (err, response) => {
|
|
if (err) {
|
|
console.error("Error sending message-------:", err);
|
|
return;
|
|
}
|
|
// console.log("Message sent successfully:", response);
|
|
// console.log("Message details:", response, response?.recipients?.items);
|
|
});
|
|
};
|
|
|