Receiving email in Node.js

70,087

Solution 1

You are looking for an e-mail client library. Currently, there are 2 options (as mentioned here):

I never used them before, but usage is pretty straight forward (according to the docs). node-imap seems to be the more stable library and it has been tested against gmail. If IMAP is an option in your environment, i'd stick with node-imap.

Solution 2

The Mailin module allows you to receive emails, parse them and post them to a webhook of your choice. It is based on simplesmtp. It also checks the dkim and spf, computes a spamassassin score and determines the message language.

Even if it does not fit your needs exactly, you can have a look at the code, it might help you. (Disclaimer: I am the maintainer of Mailin)

Solution 3

If you want the actual server in node.js check out

Solution 4

The solution that I found is mail-listener2. I was able to get up and running with this in just a few minutes, it ties in node-imap and mailparser nicely out of the box.

Share:
70,087
foobar
Author by

foobar

Updated on July 05, 2022

Comments

  • foobar
    foobar almost 2 years

    I see a lot of Node.js modules out there that sends mail through SMTP.

    But is there a module to receive mail?

  • foobar
    foobar about 13 years
    Thanks! That's exactly what I was looking for.
  • Hiteshdua1
    Hiteshdua1 about 8 years
    Can mailin listen to emails of a gmail account ? and notifies when an email has arrived. sort of like github.com/jcreigno/nodejs-mail-notifier
  • Arpit Kumar
    Arpit Kumar almost 6 years
    @schaermu, @foobar, I have tried github.com/mscdex/node-imap, It works perfectly but we need to enable LESS SECURE APP from our Gmail account (for security reasons). I want to meet the security criteria of Gmail. But from where I can get the checklist? What should be the flow (Client side and Server side) in order to access the Gmail inbox without enabling LESS SECURE APP, using this node module? Thanks.
  • Drew LeSueur
    Drew LeSueur almost 6 years
    but arent those links to servers that implement the SMTP protocol?
  • James Perih
    James Perih over 4 years
    @GrantGryczan SMTP is for both receiving and sending mail. The first link provided by Drew is literally exactly what I needed, based on the OP's question.