Send Email using G-Mail SMTP in Express/Node.js

In this arti­cle, I will demon­strate a sim­ple exam­ple of send­ing emails using G-Mail SMTP in Express/ Node.js. fortunately sending emails in express/node js pretty easy, in node.js there are many open source email libraries are available.

In this tutorial we are going to use express-mail library. For sending html emails we are going to use template engine called pugjs, this project was formerly known as Jade.

Create package.json file and keep it in any folder. Put the below code in it.

or

issue npm init command to generate package.json and after generating, issue following commands to install express js, pugjs and express mailer dependencies, npm install --save pug express express-mailer

server.js

views/email.pug

Run the app with the following command:

Then, load http://localhost:8000/ in a browser to see the output.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Karan Bhansali
Karan Bhansali
2 years ago

what is the limit of sending mails per day?

arjun
2 years ago
Reply to  Karan Bhansali

approximately 100-150 emails per day

kangelani mdingi
kangelani mdingi
2 years ago

i have this problem when im trying to run the code

{ Error: connect ETIMEDOUT 108.177.15.108:465
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
code: ‘ETIMEDOUT’,
errno: ‘ETIMEDOUT’,
syscall: ‘connect’,
address: ‘108.177.15.108’,
port: 465,
stage: ‘init’ }

and on browser

There was an error sending the email

DMCA.com Protection Status
3
0
Would love your thoughts, please comment.x
()
x