Registration and activation
This commit is contained in:
37
backend/services/emailService.js
Normal file
37
backend/services/emailService.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
import i18n from '../utils/i18n.js';
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST,
|
||||
port: process.env.SMTP_PORT,
|
||||
secure: process.env.SMTP_SECURE === 'true',
|
||||
auth: {
|
||||
user: process.env.SMTP_USER,
|
||||
pass: process.env.SMTP_PASSWORD
|
||||
}
|
||||
});
|
||||
|
||||
export const sendPasswordResetEmail = async (email, resetLink, language) => {
|
||||
i18n.setLocale(language);
|
||||
const mailOptions = {
|
||||
from: process.env.SMTP_FROM,
|
||||
to: email,
|
||||
subject: i18n.__('password_reset_subject'),
|
||||
text: i18n.__('password_reset_text', { resetLink })
|
||||
};
|
||||
|
||||
await transporter.sendMail(mailOptions);
|
||||
};
|
||||
|
||||
export const sendAccountActivationEmail = async (email, activationLink, username, resetToken, language) => {
|
||||
i18n.setLocale(language);
|
||||
const mailOptions = {
|
||||
from: process.env.SMTP_FROM,
|
||||
to: email,
|
||||
subject: i18n.__('account_activation_subject'),
|
||||
text: i18n.__('account_activation_text', { activationLink, username, resetToken }),
|
||||
html: i18n.__('account_activation_html', { username, activationLink, resetToken })
|
||||
};
|
||||
|
||||
await transporter.sendMail(mailOptions);
|
||||
};
|
||||
Reference in New Issue
Block a user