Maj smtp, reset password, et ajout afroshine
All checks were successful
Build and Push App / build (push) Successful in 10m29s
All checks were successful
Build and Push App / build (push) Successful in 10m29s
This commit is contained in:
29
lib/mail.ts
Normal file
29
lib/mail.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST,
|
||||
port: parseInt(process.env.SMTP_PORT || '587'),
|
||||
secure: process.env.SMTP_SECURE === 'true',
|
||||
auth: {
|
||||
user: process.env.SMTP_USER,
|
||||
pass: process.env.SMTP_PASS,
|
||||
},
|
||||
});
|
||||
|
||||
export const sendEmail = async ({ to, subject, html }: { to: string; subject: string; html: string }) => {
|
||||
const mailOptions = {
|
||||
from: process.env.SMTP_FROM || '"Afrohub" <noreply@afrohub.com>',
|
||||
to,
|
||||
subject,
|
||||
html,
|
||||
};
|
||||
|
||||
try {
|
||||
const info = await transporter.sendMail(mailOptions);
|
||||
console.log('Email sent: ' + info.response);
|
||||
return info;
|
||||
} catch (error) {
|
||||
console.error('Error sending email:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user