31 lines
849 B
JavaScript
31 lines
849 B
JavaScript
const nodemailer = require('nodemailer');
|
|
|
|
const transporter = nodemailer.createTransport({
|
|
host: 'smtp.ionos.it',
|
|
port: 587,
|
|
secure: false,
|
|
auth: {
|
|
user: process.env.EMAIL_USER,
|
|
pass: process.env.EMAIL_PASS
|
|
}
|
|
});
|
|
|
|
const sendVerificationEmail = async ({ nome, email, codice, applicazione }) => {
|
|
const html = `
|
|
<h2>Ciao ${nome},</h2>
|
|
<p>Il tuo codice di verifica per <strong>${applicazione}</strong> è:</p>
|
|
<h1 style="color:#007BFF;">${codice}</h1>
|
|
<p>Inseriscilo nell'app per completare la verifica.</p>
|
|
<br>
|
|
<small>Questa email è generata automaticamente. Non rispondere.</small>
|
|
`;
|
|
|
|
return transporter.sendMail({
|
|
from: `"Verifica ${applicazione}" <${process.env.EMAIL_USER}>`,
|
|
to: email,
|
|
subject: 'Codice di verifica email',
|
|
html
|
|
});
|
|
};
|
|
|
|
module.exports = sendVerificationEmail;
|