-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendEmail.js
43 lines (39 loc) · 1016 Bytes
/
sendEmail.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
41
42
43
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
// host: "smtp.office365.com", // outlook
// port: 587, // outlook
// secure: false, // outlook, true for port 465, false for other ports
host: 'smtp.gmail.com', // gmail
port: 465, // gmail
secure: true, // gmail
auth: {
user: '[email protected]',
pass: ''
},
tls: { rejectUnauthorized: false }
});
const mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'E-mail enviado usando Node!',
text: 'Bem fácil, não? ;)',
html: '<h2>Agora vai</h2><p>Texto</p>'
};
/**
* Destinatário: [email protected]
* Assunto: Título da página ~Blogs
* Corpo: URL
*
* Ou
*
* Destinatário: [email protected]
* Assunto: URL ~Blogs
* Corpo: (nada)
*/
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email enviado: ' + info.response);
}
});