15
votes

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.

2

2 Answers

7
votes

Well, sendgrid-nodejs is a more popular repository.

However, Nodemailer is the most popular module for sending emails with NodeJS. I've been using it for months and I'm very satisfied.

If you're worried about the future of your app you should consider that Nodemailer is used not just with Sendgrid, but with a lot of other competitors. So if you have a problem with Sendgrid, you could easily switch to another email delivery service without having to learn a different API.

So I suggest you to use nodemailer-sendgrid-transport, and if you find bugs, fix them with a PR :P

7
votes

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.