NodeJS

The NodeJS force is the multitude of available libraries and especially the ease to install and use them

To install a new library, we advice to use NPM (Node Package Manager). This is a NodeJS module to interact easily with NodeJS modules install dependencies, downloading new modules, ...

Once on your system, we will use it to install the email sending library. One of the most popular libraries is Nodemailer.

To install Nodemailer, simply do:

				npm install nodemailer
			

You can now use the library in your application. Here is a code example that you can adapt

				/*
				 * File Name : send.js
				 * Task : send email through Tipimail
				*/

				/*
				 * Load all the required modules
				*/

				var nodemailer = require("nodemailer");


				var transport = nodemailer.createTransport({
					host: 'smtp.tipimail.com',
					port: 25,
					auth: {
						user: 'tipimail username',
						pass: 'tipimail password'
					}
				});


				var mailOptions = {
					from: 'from@tipimail.com',
					to: 'to@tipimail.com',
					subject: 'subjet',
					html: 'HTML message',
					text: "Texte message",
					//headers: []
				};

				transport.sendMail(mailOptions, function(error, info) {
					if(error) {
						console.log(error);
					} else {
						console.log(info);
					}
				});

				transport.close();
			

Call the script

				node send.js