-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail.js
40 lines (36 loc) · 1.06 KB
/
email.js
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
31
32
33
34
35
36
37
38
39
40
import nodemailer from 'nodemailer';
import dotenv from 'dotenv';
import path from 'path';
dotenv.config();
export var remetente = nodemailer.createTransport({
host: "smtp.gmail.com",
service: "gmail",
port: 465,
secure: true,
auth:{
user: process.env.EMAIL_ADDRESS,
pass: process.env.EMAIL_PASSWORD },
tls: {
ciphers:'SSLv3'
}
});
export async function enviarTweetsParaEmail(remetente, armazenados, id){
var emailASerEnviado = {
from: process.env.EMAIL_ADDRESS,
to: process.env.EMAIL_ADDRESS,
subject: `Enviando Email com Twitter Stalker. Tweets de ${id}`,
text: JSON.stringify(armazenados),
attachments: [{
filename: `${id}.png`,
path: `./screenshots/${id}.png`,
}]
};
console.log('vai mandar');
await remetente.sendMail(emailASerEnviado, function(error){
if (error) {
console.log(error);
} else {
console.log("Email enviado com sucesso.");
}
});
}