forked from MyZubster-Ecosystem/myzubster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemail.js
More file actions
30 lines (27 loc) · 656 Bytes
/
Copy pathemail.js
File metadata and controls
30 lines (27 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
host: 'smtps.aruba.it',
port: 465,
secure: true,
auth: {
user: 'ionidaniel@pec.it',
pass: process.env.PEC_PASSWORD
}
});
async function sendPEC(to, subject, text, attachments = []) {
try {
const info = await transporter.sendMail({
from: '"Daniel Ioni" <ionidaniel@pec.it>',
to,
subject,
text,
attachments
});
console.log('📧 PEC inviata:', info.messageId);
return info;
} catch (error) {
console.error('❌ Errore invio PEC:', error);
throw error;
}
}
module.exports = { sendPEC };