Skip to content
← Back to Community
How to email someone
Profile icon
h
has Hacker Plan
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
Profile icon
ToldFable
Profile icon
Spotandjake
Profile icon
TheOceanFace
Profile icon
techgeek680
Profile icon
TikiHed
Profile icon
JunhaoZhang1
Profile icon
SkywayDeveloper
Profile icon
cmaofficialcomp
Profile icon
Coder100
Comments
hotnewtop
Profile icon
AndrewSamson

This is a rather regular issue for node JS users due to recent service instability. To be honest, I quit using it due to faults and job disruptions. You can try to find solutions in the configuration options, but I doubt it would help. Change to gmail or yahoo. It's more stable than others. Alternately, this service can establish temporary mailboxes for https://tempmaili.com/en. This is useful if you merely send messages and not link them to social networks.

Profile icon
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.

Profile icon
karenberys

Wow, I had a similar problem, bro!

Profile icon
TikiHed

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

Profile icon
Coder100

Ah yes, thank you! @Xiija

Profile icon
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.

Profile icon
Coder100
Profile icon
Coder100

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

Profile icon
Geocube101

@Coder100 Can I see the repl or Error Message

Profile icon
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' }

Profile icon
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.

Profile icon
Coder100

@Geocube101 ok, how should I do that?

Profile icon
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.

Profile icon
Coder100

@Geocube101 ok, thanks

Profile icon
theLMGN

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

This file cannot be displayed: https://storage.googleapis.com/replit/images/1542744252973_928874193accc2bf3d10805e55a9783b.pn