ROR Application Development Tips

I'm Ruby on Rails developer. I love to share my experience, technical knowledge. I work at Crypex Technologies which is developing applications in ROR for more than a decade.

How to send email without using any server side language with the help of node.js?

What is node.js ?

Node.js is a server-side platform built-in JavaScript framework

The steps to be followed :

Step 1: Install node.js

Step 2: Install npm (node package manager)

Step 3: Install node mailer by running :   “ npm install nodemailer “

Step 4: Create a file called “package.json” in your project folder and write the following code :

aj00

Step 5: Run “ npm install “

Step 6: Create a “Server.js”

aj01

Step 7: Create a form on index.html page

aj02

Step 8: Write js code form Submit button, this code will check the validation before sending mail.

aj03

Include this file on index.html by using :

“  http://js/node-mailer-contact.js  “

index.html form (view) :

aj04

Step 9: Create a method for SMTP ( Simple Mail Transfer Protocol ) in “Service.js” file through which email will be send:

aj05

Step 10: Create a method for sending email in “Server.js” file:

aj06

Step 11: Start the node js server on the terminal by running :

“ node Server.js “

It will look like :

aj07

After filling the form and clicking on “Submit” the email will get send to the respective email id and on terminal it will look like :

aj08

Source: Send Mail Using Node.js