Email Notifications Driver using Node/sendmail on a PI

Yes, when I use curl to send the request I get:
Email not sent. Cannot find "email@gmail.com" in defined email list.

I do have it defined eml_config.js in the same directory as the app.js.

david

That's where it should be:

Can you try it with a simpler eml_config.js first?

module.exports = {
    "email@gmail.com": {authuser: "email@gmail.com", authpwd: "gmailpasswd"}
};

I got past the can't find email. Seems I had to restart the service after adding the emails to the config file.

now I get no message from curl, but I get no email either.

What IP address is sendmail bound to? Loopback or 0.0.0.0?

That may be the issue, if I try using just sendmail it hangs.

EDIT:
It did eventually send, just took a while. I then run the test in Hubitat with google service and got a log:

[dev:72](http://192.168.10.30/logs/past#dev72)2019-12-23 04:47:43.743 pm [debug](http://192.168.10.30/device/edit/72)status of post call is: 408

[dev:72](http://192.168.10.30/logs/past#dev72)2019-12-23 04:47:43.740 pm [debug](http://192.168.10.30/device/edit/72)data was passed successfully

Is there a log file for the app.js that I can look at?

david

I don't know. But what shows up in the sendmail log file (/var/log/maillog)?

Dec 23 16:59:30 david-Standard-PC-Q35-ICH9-2009 sendmail[6681]: My unqualified host name (david-Standard-PC-Q35-ICH9-2009) unknown; sleeping for retry
Dec 23 17:00:01 david-Standard-PC-Q35-ICH9-2009 sm-msp-queue[6879]: My unqualified host name (david-Standard-PC-Q35-ICH9-2009) unknown; sleeping for retry
Dec 23 17:00:30 david-Standard-PC-Q35-ICH9-2009 sendmail[6681]: unable to qualify my own domain name (david-Standard-PC-Q35-ICH9-2009) -- using short name

Then it finally sends.

This is all from the command line using sendmail or mail.

I've not gotten anything from Hubitat yet. I'm not sure it is working as they authuser list never appears. I thought it said that new parameter would apppear.

EDIT:
I think something is wrong on the Hubitat side. If I hit the ip:port/email with chrome it reports the authorized addresses, and they are correct.

david

You have it entered as "http://ipaddress:3000/email", correct?

Yes, I see the Hubitat driver replying that the data was passed:

dev:732019-12-23 05:20:33.965 pm debugstatus of post call is: 408
dev:732019-12-23 05:20:33.961 pm debugdata was passed successfully

I see this for all three authorized users, reported by ip:3000/email

I can use sendmail to send emails from the VM

I can't find any logs of information on the app.js side to see what it happening.

david

What IP address is port 25 and port 587 bound to?

Whatever system defaults to. I didn't do anything with them.

I see that node is bound to TCP *:3000 (LISTEN) that seem correct.

sendmail- TCP 127.0.0.1:25 (LISTEN)
sendmail TCP 127.0.0.1:587 (LISTEN)

That's the problem. It should be bound to 0.0.0.0 - for security sendmail defaults to binding only the loopback address.

You'll need to edit sendmail.mc, then use m4 to rebuild sendmail.cf, and then restart sendmail.

Edit - here's the equivalent on my system:

odroid@odroid:~$ netstat -tan | grep '25\|587'
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN

@Sigogglin

Here are the changes you'll have to make to sendmail.c

odroid@odroid:~$ diff -u /var/backups/sendmail.mc.bak.0 /etc/mail/sendmail.mc
--- /var/backups/sendmail.mc.bak.0 2019-08-07 18:35:27.830225566 -0500
+++ /etc/mail/sendmail.mc 2019-08-31 08:48:27.658784138 -0500
@@ -54,9 +54,9 @@
dnl #
FEATURE(`no_default_msa')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
-DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
+DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=0.0.0.0')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl
-DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl
+DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=0.0.0.0')dnl
dnl #
dnl # Be somewhat anal in what we allow
define(`confPRIVACY_FLAGS',dnl

You can create a new sendmail.cf using m4 as such:
m4 sendmail.mc > sendmail.cf

OK how do I quote a post? Hitting reply on the post itself doesn't work like other forums.

anyway I now get:
netstat -tan | grep '25|587'
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN

EDIT:
It is sending emails from mail, it just takes a long time:

   Dec 23 18:46:34 david-Standard-PC-Q35-ICH9-2009 sendmail[4579]: My unqualified host name (david-Standard-PC-Q35-ICH9-2009) unknown; sleeping for retry
    Dec 23 18:47:34 david-Standard-PC-Q35-ICH9-2009 sendmail[4579]: unable to qualify my own domain name (david-Standard-PC-Q35-ICH9-2009) -- using short name

david

I've never used Docker. But under Ubuntu - there are no delays. In the old days (like 25-30 years ago), sendmail was very sensitive to permissions and name resolution delays. Your log indicates you have some name resolution issues.

All that aside, now that sendmail is bound to 0.0.0.0 - can you send mail from HE (even if it is delayed)?

No, I get nothing from Hubitat. The log file in Hubitat says it parsed OK, but I've never gotten an email from it yet. Just from sendmail in Ubuntu.

david

Hello.
I seem to be bogged down at the start.
I setup ssmtp and am able o send myself an email.
However, after I install everything, I get the following error message:

root@RASPI:/home/pi/Hubitat-DoNS/DoNetStuff# node app.js
Created route: /email for controllers/email/index.js
events.js:183
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE :::3000
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at Function.listen (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/express/lib/application.js:618:24)
at Object. (/home/pi/Hubitat-DoNS/DoNetStuff/app.js:17:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
root@RASPI:/home/pi/Hubitat-DoNS/DoNetStuff#

Any ideas what I'm doing wrong?

Yes another instance is already running. Port 3000 is taken and it's erroring out because of this.. Did you set up the systemd instance? Maybe that's running.

1 Like

I did setup the systemd instance.
OK>
Please excuse my Linux ignorance.
How do I cancel one instance from running?
pi@RASPI:~/Hubitat-DoNS/DoNetStuff $ systemctl status DoNetStuff
● DoNetStuff.service - DoNetStuff for Hubitat Service
Loaded: loaded (/etc/systemd/system/DoNetStuff.service; enabled; vendor preset: enabled)
Active: inactive (dead)

sudo systemctl stop DoNetStuff.

OR just do a restart..

sudo systemctl restart DoNetStuff.