Email Notifications Driver using Node/sendmail on a PI

I think that did it!!!!
pi@RASPI:~ $ sudo systemctl daemon-reload
pi@RASPI:~ $ sudo systemctl start DoNetStuff
pi@RASPI:~ $ sudo systemctl status DoNetStuff
● DoNetStuff.service - DoNetStuff for Hubitat Service
Loaded: loaded (/etc/systemd/system/DoNetStuff.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-01-30 22:19:35 EST; 1min 8s ago
Main PID: 12699 (npm)
CGroup: /system.slice/DoNetStuff.service
├─12699 npm
├─12740 sh -c node app.js
└─12742 node app.js

Jan 30 22:19:35 RASPI systemd[1]: Started DoNetStuff for Hubitat Service.
Jan 30 22:19:36 RASPI npm[12699]: > donetstuff@1.0.0 start /home/pi/Hubitat-DoNS/DoNetStuff
Jan 30 22:19:36 RASPI npm[12699]: > node app.js
Jan 30 22:19:37 RASPI npm[12699]: Created route: /email for controllers/email/index.js
Jan 30 22:19:37 RASPI npm[12699]: Server running on port 5000

2 Likes

THANKS A LOT!!! GUYS!!!!

(On to my next challenge - getting the Hubitat part!
Thanks again, for all your hard work on this:
@aaiyar and @erktrek
It's much appreciated....

2 Likes

To be clear - all @erktrek ...

Happy to help!

Thanks for bringing those quirks to my attention! Am working on a fix now.

E.

1 Like

Just to follow up - the issue was "port" defined as lowercase when by convention it really should be uppercase. This would cause the systemd service to fail if the same port was in use or just never switch to desired port. This has now been fixed and commited to Github.

Also in the systemd service file itself I had some entries that were relevant to my dev server (I'm now running on a vm instead of a pi) - changed info back to be more "pi" centric.

2 Likes

OK, I see I'm rather late to this party but this may be helpful to somone.

I'm playing with the pre-beta2 version of @kevin's MQTT app/driver ([BETA] MQTT app) and looking forward to a non-beta release for several uses. This app is publishing all events (at this time) to a mosquitto (not a typo, really is spelled that way) MQTT broker on a Linux box. It is simple to write an MQTT client, even in a bash script, to send email or take any action you like when an event of your choosing comes out of HE via the broker. But wait, there's more! @kevin's app is bidirectional so you can also have any system in your control send events into HE as well.

If this sounds too complex trust me, it isn't. I'd never heard of MQTT 3 weeks ago and was able to get all the pieces in place in an evening, including educating myself on the topic. There are many code examples in bash, python, C, C++, COBOL. OK, kidding on COBOL but you get the idea.

Have you looked at Node-RED? :wink:

Heard of it but went this route based on the experience and advice of a friend who's been toying with Zigbee, Z-wave, Tasmota, and HA for several years now.

So it's more of an opensource control platform with a visual flow design system.. very flexible and powerful. I've moved all my RM rules over to it and have a weather station communicating via MQTT. I use that for email notifications now as well. I think MQTT is awesome and @kevin's project is very cool. With NR I can hook into that instead of the Maker API if I want. If you have time I recommend you check it out.

edit: I should mention I don't think it replaces HE just enhances the capabilities while (possibly) reducing overhead.

Thank you, @erktrek, I'll do so if for no other reason than to broaden my knowledge. This stuff is still pretty new to me as I was "making do" with an X10 system I started in the '80's until I jumped on HE a little over 2 months ago.

1 Like

The X10 stuff was fun - even better when you hooked up the "active home" pc interface (still have one of those in my basement). I did not get into it as much as my dad did - there were too many issues with connectivity and trying to get things just right. I took the plunge in HA with SmartThings when it was on kickstarter.. it's been a fun frustrating journey...

I still have the interface card for the Apple //e in my basement! :astonished: It hasn't been out of the boxes in, oh, 20 years? Until I dropped the whole system I was using the controller from Steve Ciarcia's project in Byte magazine. Ah, the good ol' days...when I wrote 6502 assembly in my sleep.

Nice! Cut my teeth on Apple ][e's - programming touch screen monitors for mall kiosks. Fried a computer by plugging in a printer card backwards. Also messed around with 6502 on the C64 wrote some minor graphics stuff. good times!

Revising an old thread.

I'm trying to install DoNetStuff using a windows server. This is already successful for Google Assistant Relay and InfluxDB.

I'm not very familiar with RPi, and not sure what to change with the repo. I can get things set up in a CMD shell, and when I go to the [ip_address]:[port]/email, I see the email address I'm trying to use (a gmail account). Then, in Hubitat, I can type a text statement and click "Device Notification". The logs show that the data was passed successfully and "status of post call: 408"

Any help? I'm lost

Hello & welcome to Hubitat:
I got this approach working with a RPI (linux) machine.
Let's start at the beginning.
Error 408:
The HyperText Transfer Protocol (HTTP) 408 Request Timeout response status code means that the server would like to shut down this unused connection. It is sent on an idle connection by some servers, even without any previous request by the client.

In general that means that nothing is being listened to.

Did you get "sendmail" working?
Does that work, for sure?
Is the relay working? On what port?

2 Likes

I only got 2 responses in the Hubitat logs:

status of post call is: 408
data was passed successfully

I'm not sure what "sendmail" is, so I don't know if that works (would need some help with how to check).

The GAR works just fine (port 3000). I believe I've changed DoNS to port 5000 (made the change in the file "app.js" as well as "DoNetStuff.service").

I can use a web browser to check [ip]:5000/email. I got a response of 4 email addresses (3 that were part of the eml_config.js and 1 that I added which is my gmail address).

Other than that, I'm not sure what next steps to check.

From wikipedia:
Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the Internet.

In other words, it's comes with Linux.
From your prevbious note, you don't want to use a RPI, or some other Linux box, you want to use windows. Is that correct?

However, I did find this:
sendmail .exe is a simple windows console application that emulates sendmail's -t option to deliver emails piped via stdin. it is intended to ease running unix code that has /usr/lib/ sendmail hardcoded as an email delivery means.
And this, on how to use sendmail on windows:


or this:

The DoNetStuff service interfaces with sendmail to get your email relay service to work. So, if you're going to use a windows box, then you will have to modify the Hubitat driver to talk to your windows machine to send the mail.

1 Like

if your interested i have a command line exectable that i wrote many years ago for windows that implements sendmail smtp

defaults to port 25 non authentications

return SendMail(remote_name,fromaddr,toaddr,subject,content,FALSE);
}

i have another version that will interpret the last parameter as a file and send the entire file as the content.

E:\utils>sendmail mail.server.com kahn@lgk.com kahn-hubitat@lgk.com "test" test.txt
rvalue = OK

E:\utils>sendmailf mail.server.com kahn@lgk.com kahn-hubitat@lgk.com "test" test.txt
rvalue = OK

Hmmm....

I'm not sure what I can/should do. I'm still not clear on the sendmail thing, but I already have some automations using the SMTP commands in powershell (simply executing a hardcoded bat file).

What I'm wanting to do is to use Hubitat (perhaps really WebCore) to send a SMS text to a phone when specific things happen (like the front door opens).

I'm not a coder, and struggle with following the groovy text (write it in FORTRAN and I'll feel more comfortable). I was hoping there were some simple edits to the DoNetStuff install on a RPi that would get this to run on a windows box.

If you're using webcore, you can directly send email to the email2sms gateway for your provider. There is no need for this integration (or any other).

1 Like