const axios = require("axios"); const senderEmail = "ecoconnect@trial-ynrw7gy0qxol2k8e.mlsender.net"; const { getApiKey } = require("./apiKey"); async function sendEmail(recipientEmail, title, content) { try { const apiKey = await getApiKey("mailersend_api_key"); const response = await axios.post( "https://api.mailersend.com/v1/email", { from: { email: senderEmail, }, to: [ { email: recipientEmail, }, ], subject: title, text: content, html: content, }, { headers: { "Content-Type": "application/json", "X-Requested-With": "XMLHttpRequest", Authorization: `Bearer ${apiKey}`, }, } ); console.log("Email sent successfully:", response.data); } catch (error) { console.error( "Error sending email:", error.response ? error.response.data : error.message ); } } const ecoconnectEmailLogoUrl = "https://onedrive.live.com/download?resid=FDC8D8692E9A43C0%21425747&authkey=%21ADT2uhKbMIG4iqw&width=1310&height=212"; async function sendPasswordResetEmail(email, firstName, resetToken) { let dateTimeNow = new Date().toLocaleString(); let emailContent = `
We have received your request to reset the password.
Click the
button below to do so.
This reset portal is opened on ${dateTimeNow}, for 60 minutes.
If you have not made a request to reset the password, feel free to ignore this email.
Best regards,
ecoconnect administrators
ยท Connecting neighbourhoods together