Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving email in Node.js

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

But is there a module to receive mail?

like image 941
foobar Avatar asked Mar 09 '11 04:03

foobar


People also ask

CAN node JS send emails?

Whether you're building the next Gmail, cutting-edge email marketing software, or just want to program notifications into your Node. js app, it's easy to send emails using readily-made tools and services. Node. js is one of the most popular (if not the most popular) server-side runtime environment for web applications.

Can I use SMTP to receive email?

The Simple Mail Transfer Protocol (SMTP) is used for sending and receiving e-mail between e-mail clients and servers.

How do I use IMAP in node JS?

const Imap = require('imap'); const inspect = require('util'). inspect; const simpleParser = require('mailparser'). simpleParser; const imap = new Imap({ user: '[email protected]', password: 'mypassword', host: 'imap.gmail.com', port: 993, tls: true }); function openInbox(callback) { imap.

How do I send or receive emails?

Create and send an emailSelect Home > New Email. Add recipients, a subject, and a message in the email body. Select Send.


2 Answers

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

  • node-imap (IMAP)
  • n3 (POP3, experimental)

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.

like image 103
schaermu Avatar answered Sep 26 '22 21:09

schaermu


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)

like image 42
Flolagale Avatar answered Sep 24 '22 21:09

Flolagale