Created
September 23, 2020 13:53
-
-
Save muhsalaa/5bc9bc9f00425f6311515bc46b9afdf1 to your computer and use it in GitHub Desktop.
nodemailer setup, work for yandex and google
This file contains 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
const nodemailer = require('nodemailer'); | |
const smtpTransport = require('nodemailer-smtp-transport'); | |
const transporter = nodemailer.createTransport( | |
smtpTransport({ | |
service: 'yandex/google', | |
host: 'smtp.yandex.ru/smtp.gmail.com', | |
auth: { | |
user: '[email protected]', | |
pass: 'yourEmailPassword', | |
}, | |
}) | |
); | |
function sendEmail() { | |
const mailOptions = { | |
from: '[email protected]', | |
to: '[email protected]', | |
subject: 'Hola como estas', | |
text: 'Berkabar ya', | |
}; | |
transporter.sendMail(mailOptions, (err, info) => { | |
if (err) throw err; | |
console.log('Email sent: ' + info.response); | |
}); | |
} | |
sendEmail(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment