Additional Setup for SMTP Server Node

Regarding the solution below from a previously closed topic (ristomatti), could someone provide additional information on how to receive local emails using this SMTP server function node?

  1. How do you setup an MX record on a domain and point it at the node red server?
  2. Does the port number matter if it is only to be used locally?

In summary what additional steps are required to receive an email locally after this flow is created?


For those curious - it turned out to be a lot easier than I expected.

Function node code (note that I'm using [node-red-contrib-function-npm)(https://github.com/ntsaini/node-red-contrib-function-npm) :

const {SMTPServer} = require('smtp-server');
const {simpleParser} = require('mailparser');

const server = new SMTPServer({
  secure: false,
  logger: false,
  disabledCommands: ['AUTH', 'STARTTLS'],

  onData: function (stream, session, callback) {
    simpleParser(stream, {
      skipTextToHtml: true,
      skipTextLinks: true
    }).then(parsed => {
        node.send({payload: parsed});
      })
      .catch(err => {})
      .finally(callback);
  }
});

server.listen(1825);

return null;

Welcome to the community!

Unfortunately I definitely would not recommend this prototype/hack setup I made to be used on the open the internet.

In my case the intended purpose was to be able to receive image/motion notifications from IP cameras by using their email support but without sending anything out of the local network.

Hi Ristomatti,

That is exactly my intent... to use this setup with IP cameras only on my local network. This seems to provide a nice solution that prevents polling an external email server also with improved latency. Can you provide any additional information on the implementation?

In your example, how is the email address "nodered@kukkis.local" linked to the SMTP server running in node red? What additional setup is required. Thanks for any information you can provide.

Spookily - I am also just adding an MTA (Mail Transfer Agent) node to the default email nodes. This will listen on a port (typically 25) and can grab incoming smtp messages for further processing. It's not secure so not for production use, as it is intended for testing outgoing mail - but can do what you suggest without need for an email server.

The email address is just the email receiver address set on the camera. It could be anything as the only thing that matters is the SMTP server IP address. The SMTP server IP address should be of the device running Node-RED.

I also set the sender email address of the camera to something that will identify the camera. This way you can identify which camera a message is from on the Node-RED side.

So it's just for metadata. No need to setup DNS records. :slightly_smiling_face:

One thing to note though. I tried with two cameras of different brands. The other one only had support for SSL/TLS SMTP servers and while the other one had SSL and unencrypted, it did not seem compatible with the SSL provided by the smtp-server package. So I added two separate server definitions on the Node-RED side.

I'd post the function node code if I had access to the Node-RED instance but unfortunately the (remote) router failed to boot correctly after I did some changes a couple of days ago and I'm blocked from access before I'll go on site to our cottage. :unamused:

Thank you! That is exactly the information that I was trying to find. That got me up and running. I can now receive emails using the SMTP function node above.

1 Like

While doing this hack I was quite surprised there was no contrib node to act as an SMTP server (not one that I got working anyhow).

Great to hear something is worked on. It seems to me like a simple way to integrate especially some legacy devices.

For this use case it was a lot easier than setting up an FTP server or SMB/NFS shares which seem to be the other common methods for IP cameras to communicate.

I've tried all of the above and I've had difficulties with setting up authentication and/or file permissions to work with different brands of cameras. Besides the SSL/TLS issue mentioned above, SMTP seems like a common denomitor with most consumer level cameras I've owned.

Yes. I’m just looking at the micromta library. Does seem nice and lightweight.

Does it also support SSL/TLS? This was needed for Reolink cameras in my case.

In theory yes but I’ve not implemented it as I’ve only done it for testing and certs are a pain :slight_smile:

1 Like

No certs where needed with my hack setup using smtp-server. In my case it was only to allow a camera to connect which didn't have any other option. It didn't seem to need certificates. If it would have, I would've ditched the idea as certificates are indeed a pain in the ass. :slightly_smiling_face:

I’ll maybe give yours a try as it’s by the same guys as the rest of nodemailer we use. Hopefully the extra libs may not be too large (for something not a lot of folk would use)

Yea they seemed quite feature rich so highly possible space could be wasted in including them. Especially if only supporting only a subset of the features and the node is planned to be in the core node set...

A quick look suggests the overhead on what we already have is quite small - so I'll investigate further tomorrow and shamelessly re-use your code if I may.

1 Like

New email node version pushed that includes email MTA node

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.