Ask coding questions

← Back to all posts
Can you send emails in repl?
TheH4ck3r (11)

I'm trying to send an email programmatically trough a repl in Node.js or Python. I have tried Nodemailer so far, but it won't work. Any tips?

Comments
hotnewtop
Coder100 (18917)

It won't work because of security.
Search up turn on less secure apps for <application>
for <application> it can either be gmail or hotmail depending on your emial.

codingjlu (482)

Yes you can (in Node.js at least); PHP doesn't work.

Dart (1201)

yes, if you use an email server, just look up "how to send email using <insert lang here>"

ruiwenge2 (1158)

yes, you can!
do the following code in node.js:

const gmail = require("gmail-send");

function sendEmail(){
  const send = gmail({
    user: "YOUR USERNAME",
    pass: "YOUR PASSWORD",
    to:   "RECEIVERS'S USERNAME",
    subject: "SUBJECT"
  });
  send({html: "TEXT"}, (error, result, fullResult) => {
    if (error) console.error(error);
    console.log(result);
  });
}
ruiwenge2 (1158)

one important thing is that in your google account settings, you have to turn on less secure app access

Yimmee (10)

@ruiwenge2
So it didn’t work out....
You do need that on.

Yimmee (10)

@ruiwenge2
Also, html is used for html. It can be plain, but it can also be html.
There’s no difference, but I think you can use text for plain text.

ch1ck3n (2373)

i dont think replit allows email sending :(