How to email someone
Coder100 (6777)

I am trying to learn how to email somebody using nodeJS. I have seen some answers online elsewhere, but they don't work. Can someone please tell me how to make a repl that can email someone and actually works?

You are viewing a single comment. View All
Geocube101 (590)

var nodemailer = require('nodemailer');

var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'yourpassword'

var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Sending Email using Node.js',
text: 'That was easy!'

transporter.sendMail(mailOptions, function(error, info){
if (error) {
} else {
console.log('Email sent: ' + info.response);

I found this on and it works just fine for me.

Coder100 (6777)

@Geocube101 It doesn't work, for some reason, google says that you can only sign-in using a google app :(

Geocube101 (590)

@Coder100 Can I see the repl or Error Message

Coder100 (6777)

@Geocube101 ok: { Error: Invalid login: 535 5.7.3 Authentication unsuccessful []
at SMTPConnection._formatError (/home/runner/node_modules/nodemailer/lib/smtp-connection/index.js:606:19)
at SMTPConnection._actionAUTHComplete (/home/runner/node_modules/nodemailer/lib/smtp-connection/index.js:1335:34)
at SMTPConnection._responseActions.push.str (/home/runner/node_modules/nodemailer/lib/smtp-connection/index.js:1293:18)
at SMTPConnection._processResponse (/home/runner/node_modules/nodemailer/lib/smtp-connection/index.js:762:20)
at SMTPConnection._onData (/home/runner/node_modules/nodemailer/lib/smtp-connection/index.js:558:14)
at TLSSocket._socket.on.chunk (/home/runner/node_modules/nodemailer/lib/smtp-connection/index.js:709:51)
at TLSSocket.emit (events.js:180:13)
at addChunk (_stream_readable.js:274:12)
at readableAddChunk (_stream_readable.js:261:11)
at TLSSocket.Readable.push (_stream_readable.js:218:10)
code: 'EAUTH',
response: '535 5.7.3 Authentication unsuccessful []',
responseCode: 535,
command: 'AUTH LOGIN' }

Geocube101 (590)

@Coder100 I've has this error before. I believe it is because of gmail security settings. I used an outlook account for logging in and sending emails. Try using an outlook account.

Coder100 (6777)

@Geocube101 ok, how should I do that?

Geocube101 (590)

@Coder100 set service to 'outlook'. The user is your outlook account email and pass is the password for that email. from is also equal to the outlook email.

theLMGN (3)

@Coder100 Hey, wouldn't recommend putting your username and password in a public thing