Ask coding questions

← Back to all posts
How to email someone
Coder100

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?

Voters
Spotandjake
TheOceanFace
techgeek680
TikiHed
JunhaoZhang1
SkywayDeveloper
cmaofficialcomp
Coder100
Comments
hotnewtop
Fantik24

This is a fairly common problem for many node JS users because this service has been unstable lately. To be honest, I stopped using it a long time ago precisely because of malfunctions and interruptions in work. You can look for solutions in the configuration settings, but I don't think it will help, to be honest. Still, switch to gmail or yahoo. It's much more stable than other mailboxes. As an alternative, you can use this service https://tempmail.dev/ to create temporary mailboxes. This is convenient if you do not link them to social networks or something similar but only send messages.

karenberys

Wow, I had a similar problem, bro!

TikiHed

you can get thru with gmail if you change a setting here ... https://myaccount.google.com/lesssecureapps

Coder100

Ah yes, thank you! @Xiija

Geocube101

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) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});

I found this on https://www.w3schools.com/nodejs/nodejs_email.asp and it works just fine for me.

Coder100
Coder100

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

Geocube101

@Coder100 Can I see the repl or Error Message

Coder100

@Geocube101 ok: { Error: Invalid login: 535 5.7.3 Authentication unsuccessful [DM6PR03CA0072.namprd03.prod.outlook.com]
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 [DM6PR03CA0072.namprd03.prod.outlook.com]',
responseCode: 535,
command: 'AUTH LOGIN' }

Geocube101

@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

@Geocube101 ok, how should I do that?

Geocube101

@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.

Coder100

@Geocube101 ok, thanks

theLMGN

@Coder100 Hey, wouldn't recommend putting your username and password in a public thing
https://repl.it/@Coder100/RosybrownIntentionalHacks

https://storage.googleapis.com/replit/images/1542744252973_928874193accc2bf3d10805e55a9783b.pn