EvalueTonSavoir/server/config/email.js

49 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2024-03-29 20:08:34 -04:00
const nodemailer = require('nodemailer');
const dotenv = require('dotenv');
dotenv.config();
class Emailer {
constructor() {
this.senderEmail = process.env.SENDER_EMAIL;
this.psw = process.env.EMAIL_PSW;
this.transporter = nodemailer.createTransport({
service: process.env.EMAIL_SERVICE,
auth: {
user: this.senderEmail,
pass: this.psw
}
});
}
registerConfirmation(email) {
this.transporter.sendMail({
from: this.senderEmail,
to: email,
subject: 'Confirmation de compte',
text: 'Votre compte a été créé avec succès.'
});
}
newPasswordConfirmation(email,newPassword) {
this.transporter.sendMail({
from: this.senderEmail,
to: email,
subject: 'Mot de passe temporaire',
text: 'Votre nouveau mot de passe temporaire est : ' + newPassword
});
}
quizShare(email, link) {
this.transporter.sendMail({
from: this.senderEmail,
to: email,
subject: 'Un quiz vous a été transféré !',
text: 'Veuillez suivre ce lien pour ajouter ce quiz à votre compte. '+ link
});
}
}
module.exports = new Emailer();