Learn to Code via Tutorials on Repl.it!

← Back to all posts
Send Emails with Nodemailer!


Today you will learn how to send emails using nodemailer! Now all you need is a new google account. You will see why!

Getting started and authorizing!

Lets get started by installing nodemailer!

Ok we got that done! Now, here comes the long part! We will need to authorize ourselves to send emails!
So, you will put the following code:

And run the repl! Done! Right? No, you will get an error! To fix this, go here to enable less secure apps! Ok, hopefully you wont get any errors. But just one more thing! You need to keep your gmail and password private! (Unless you have a private repl) To do this, we will create a .env file! So go do that, and enter the following into the .env file:

And put this in the index.js file:

But. I think that is how I got hacked! So I would highly recommend creating and using an alternative account! Ok, now lets update the authorization!

And that should work! Run the repl to see if you dont have errors, and continue reading this tutorial.

Sending the Email!

Now lets get to the part where we send the email. To do this, put the following code:

And there we go, now all we need is to add some code to send the email! Enter the following code:


So now you have sent an email using nodemailer! Let me know if you experience any errors or if you have questions! Thank you!


What language is it?


@BryceBrower Node.js