Last active
May 17, 2021 22:50
-
-
Save alanhoff/608209204a958a26d5ba to your computer and use it in GitHub Desktop.
Enviando e-mails usando Node.js e o nodemailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enviando e-mails usando o Node.js e o famoso nodemailer | |
var nodemailer = require('nodemailer'); | |
// Vamos criar a conta que irá mandar os e-mails | |
var conta = nodemailer.createTransport({ | |
service: 'Gmail', // Existem outros services, você pode procurar | |
// na documentação do nodemailer como utilizar | |
// os outros serviços | |
auth: { | |
user: '[email protected]', // Seu usuário no Gmail | |
pass: 'huehuebrbr' // A senha da sua conta no Gmail :-) | |
} | |
}); | |
conta.sendMail({ | |
from: 'Seu Nome <[email protected]>', // Quem está mandando | |
to: 'Alan Hoffmeister <[email protected]>', // Para quem o e-mail deve chegar | |
subject: 'Estou testando seu gist', // O assunto | |
html: '<strong>Oi Alan!</strong><p>Estou testando seu gist para enviar e-mails, amo você!</p>', // O HTMl do nosso e-mail | |
}, function(err){ | |
if(err) | |
throw err; | |
console.log('E-mail enviado!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment