mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
|
|
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();
|