Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SendGrid-nodejs or Nodemailer?

There are at least two ways to send email from Nodejs using SendGrid:

  1. Sendgrid provides a Nodejs library called "SendGrid-nodejs." They're actively supporting Sendgrid-Nodejs (last update 29 days ago).
  2. Nodemailer supports sendgrid and seems to be extremely popular. SendGrid posted an article about using this combination: Sending email with Nodemailer and Sendgrid.

Edit 2

SendGrid have ended support for nodemailer-sendgrid-transport as of today.

So, if you're starting on a project now, I would suggest going with sendgrid-nodejs.


Original question:

Edit to make the question less opinion-based: What are the pros and cons to each approach? I have googled for days and not seen any comparison of the two. There is another StackOverflow question asking for differentiation between the two (among several other things) which has gone unanswered. So surely the answer to this will help others.

My specific usage, in case it helps focus the answers: I want to allow users of an iPhone app to invite others to use the app. They'll see the default invitation text in the app, and can customize it. The customized text is sent to my Nodejs server and added to a job queue. As the queue is processed, emails are sent. I want the emails to look nice, so I want to use HTML email templates (and a plaintext alternate body).

Scale-wise, this will start out very small but if the app is succssful could scale up rapidly.

like image 965
stone Avatar asked Mar 04 '15 21:03

stone


People also ask

Which is better SendGrid and Nodemailer?

Well, sendgrid-nodejs is a more popular repository. However, Nodemailer is the most popular module for sending emails with NodeJS.

Why do we use SendGrid?

SendGrid is a cloud-based SMTP provider that allows you to send email without having to maintain email servers. SendGrid manages all of the technical details, from scaling the infrastructure to ISP outreach and reputation monitoring to whitelist services and real time analytics.

Can I use Nodemailer in production?

Bookmark this question. Show activity on this post. Before changing some settings, e.g. host and port, it was working fine locally, but just won't work on production.


1 Answers

You'll find that you can achieve what you want to do using either library (nodemailer-sendgrid-transport was written by SendGrid too!) but given you suggest that you want to use HTML templates and plain text alternatives, you might want to take a look at using the SendGrid Node JS library because it'll give you easier access to some more advanced features, such as:

Template Engine - Which allows you to manage both HTML and plain text templates inside the SG dashboard rather than in your code - this could be handy for making quick changes, without the need to redeploy your app to production.

Advanced Suppression Management - Which allows you to group emails that users can then unsubscribe from, rather than completely unsubscribing from everything, ever.

It's worth noting that you could still use both these features with NodeMailer and nodemailer-sendgrid-transport, but the SendGrid NodeJS library directly exposes methods for these features.

Like I said, you can achieve what you want with either but I thought it was worth pointing out a few SendGrid specific things.

like image 143
Martyn Davies Avatar answered Sep 21 '22 08:09

Martyn Davies