Sending Email is an important Aspect for applications for notifying users,registering users and Announcement to users.However Email keeps the Application and the User interactive and stay updated for recent changes and notify.Recently i have used G-Mail for sending mails for my client,However this is Easy in PHP,Where in node.js there are two popular library to do this and send mail to your clients pragmatically from node js application.mailer is depreciated in favor of nodemailer.if you need attractive html emails better learn any templating language EJS,JADE to integrate with the email.there are seperate npm for email templates too.
Reference : Download app Zip | mailer | nodemailer
Installation :
- npm install nodemailer -g
- npm install mailer -g
these both node js modules are popular one to send mails programaticaly.Recently i utilized mailer for my cloud project.however there are lot of API to send mails like sendgrid,mailgun and lot of mail exchange service.
Mailer :
Mailer library is also efficient to use but it has been depreciated in favor of nodemailer library in github.However it is working well, and i am using it up in my recent cloud node project.Add your gmail account/password.
Node-mailer :
here just add nodemailer and create a variable ,with configuration details creating a Transport SMTP for mail service as Gmail,and here comes authentication with Gmail username and password.
Mailer :
Mailer library is also efficient to use but it has been depreciated in favor of nodemailer library in github.However it is working well, and i am using it up in my recent cloud node project.Add your gmail account/password.
Node-mailer :
here just add nodemailer and create a variable ,with configuration details creating a Transport SMTP for mail service as Gmail,and here comes authentication with Gmail username and password.
Integration with Express :
While you could simply integrate with express app with routes.Learn here to create Express App Routes.
var http = require("http");
var express = require("express");
var app = express();
app.get("/mailer",function(res,req){
//your mailer logic here to send mail
});
app.get("/nodemailer",function(res,req){
//your nodemailer logic here to send mail
});
http.createServer(app).listen(3000);
Thus we had integrate with express and tested our Email Sending application,I havent created any fault tolerant Exceptions but sure Errors will be thrown if something goes wrong.i am leaving it in your side to handle run time Errors.
Email App Screenshots :
- have a look at the screenshot mail sent from my Node.js app via Gmail account SMTP.
- i have logged the request and response of Mail.
- Mails using both mailer and node mailer library.
You could attach mail attachments in your mail.read their documentation for complete details and you coud send HTML emails by using html as parameter,however there are still Email Template from Jade,HBS and EJS templates.
For Errors/bugs/comments/suggestions just comment it out or mail me [email protected] or connect with me in Facebook/Twitter/Linkedin/Google+ and chat for more in detail regarding this post and integrations.share is care.Do comments.
1 comments:
Hi how can i send a file html? i mean, i don't want to do something like:
var html = {
'Welcome
'
}
Post a Comment
feel free to post your comments! Don't Spam here!