Email Notifications Driver using Node/sendmail on a PI

Yeah, whatever I define in Sendmail as my "MASQUERADE_AS" it modifies and makes that the email address that I am sending to. So, there is no way to send to more than one domain.

Update: And now it's not sending anything again and the only way to try to set it up is to totally re-install Raspbian. Yeah, I'm giving up on this. Sorry man....but this is not working anymore. It's not your driver or the nodeJS app but Sendmail just won't work. I recommend pulling it until you can fix it it (if you want).

I've found a write-up on nodemailer that might be useful. It seems that you are using that already, just also using Sendmail. Seems like ti should be pretty easy to swap. I might give it a try.

1 Like

Yeah I will give it a shot. Should be fairly straightforward I think. Some providers block sending via smtp except through their servers and you have to play relay games OR use an alternate port.

So clearly haven't looked at this in a while.. I am in fact already using NodeMailer. I just need to not send via the sendmail transport.. or make it a separate option (still works for me).

It was working for me before I had to totally rebuild that Pi Zero W. It totally stopped booting the other day and I have no idea why. It monitors my power for power outages and does my email/text notifications because I have it set up on a UPS with other networking equipment. Plus, I got a bunch of them for $5 a few months back so it was cheaper than using an ESP8266 board! :slight_smile: I'm either doing something completely differently in setting up sendmail this time or it just isn't working the same with Buster that it was with stretch. It is the oddest thing. It would be easier to try and debug if I didn't have to totally re-flash raspbian once it gets "lost" but there is no way that I have found to restore sendmail once it has gotten screwed up. I tried apt remove and purge and nothing recreated the /etc/mail folder and the functions once they are messed up.

I updated the driver and nodejs code.. you can clone the new stuff from github..

Install new Node code, install new driver code then edit the preferences. Warning - User/Pwd get sent unencrypted for now. Make sure to "save preferences". You can use the "Device Notification" box to send a test message.

1 Like

Oh, you put all the settings for the server into Hubitat...that's an interesting way to do that. I was thinking it would be easier to store on the server in a json file. That way they don't have to be passed back and forth from Hubitat or stored on the hub. But I will give it a try later tonight or tomorrow. Thanks so much!!

I'm getting the following error when I try to use SMTP. When I try to use Gmail it gives me a security warning and doesn't let it go through.

{ Error: Invalid greeting. response=SSH-2.0-OpenSSH_7.9p1 Raspbian-10: SSH-2.0-OpenSSH_7.9p1 Raspbian-10
    at SMTPConnection._actionGreeting (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:1024:27)
    at SMTPConnection._processResponse (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:764:20)
    at SMTPConnection._onData (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:570:14)
    at Socket._socket.on.chunk (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:522:47)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:601:20)
  code: 'EPROTOCOL',
  response: 'SSH-2.0-OpenSSH_7.9p1 Raspbian-10',
  command: 'CONN' }

The server from my ISP says it uses IMAP with SSL on port 587 for outgoing mail and it does require authentication. I confirmed my email and password is correct too.

UPDATE: Enabling less secure apps got Gmail to work. But if we're able to iron out the other issue, I'd much rather use that login as it isn't tied to every login under the sun like my Google account is. :slight_smile:

Update 2: So, I remember that I still had another microSD laying around with an old install I used before. So, I have it up and running using the sendmail function now. However, I'm going to go in and see if I can reproduce these settings on Raspbian Buster and see if that is really the culprit or not.

Yeah I was just doing it quickly. Ultimately as a preference in HE it's the most flexible but like you pointed out the most insecure. Maybe I can do some encryption or something on the fields before sending. Still using an http call on the backend of course.

Hmmm that does not occur on my smtp server. Did you select SMTP or SMTPS? SMTPS uses 587... I elected (for now) not to put the port in the preferences but maybe I should change that.

I tried SMTPS and got a different error:

----------------
{ host: 'mail.twc.com',
  port: 587,
  secureConnection: true,
  auth: { AUTH INFO REMOVED},
  tls: { rejectUnauthorized: false, ciphers: 'SSLv3' } }
================
{ from: 'Ryan',
  to: 'EMAIL ADDRESS REMOVED,
  subject: 'Hubitat Notification',
  text: 'This is a test.' }
{ Error: Mail command failed: 550 5.1.0 ESMTP server not available AUP#O-1070
    at SMTPConnection._formatError (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:605:19)
    at SMTPConnection._actionMAIL (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:1370:34)
    at SMTPConnection._responseActions.push.str (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:857:18)
    at SMTPConnection._processResponse (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:764:20)
    at SMTPConnection._onData (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:570:14)
    at TLSSocket._socket.on.chunk (/home/pi/Hubitat-DoNS/DoNetStuff/node_modules/nodemailer/lib/smtp-connection/index.js:710:55)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
  code: 'EENVELOPE',
  response: '550 5.1.0 ESMTP server not available AUP#O-1070',
  responseCode: 550,
  command: 'MAIL FROM' }

Maybe it's using port 465? It's not seeing the smtp server for some reason. Port's not firewalled is it?

Also your From address should be your Spectrum email.. I think..

I don't have a spectrum email. My address for the server ends with rochester.rr.com which is my old RoadRunner (Time Warner) email address. Those credentials work in the other setup.

Okay sorry was googling furiously.. That "From" address says "from: Ryan" - maybe put your RR email in there?

Was looking at this old thread..

Also am about to update - moving the auth user/pwd to a config file on the Node server for better security. Like you am nervous about user/pwd on HE.

Wait...I have the authuser set to my RR email address, that's what I removed. The from line has to be an email address? The old version always came from the address pi@rochester.rr.com, which isn't really valid. It still used the authuser info.

So I'm not sure I guess it depends on your provider. From that link above it was suggested that TW was doing some reverse lookups from the From address (I could be mistaken though).

It seems to be working for me but I am running my own server. Am still looking into.

So, i have new data....using sendmail is definitely broken in Buster vs. Stretch. I have the exact same setup in both, I even copies the submit.mc file from one to the other, and on Stretch it works but on Buster it does not.

Hate to ask the obvious but is sendmail installed properly?

Not Raspbian but general debian instructions..

Obvious?!? This is Linux....NOTHING IS EVER OBVIOUS!!!! Why would it be different for Buster?!?!?! But I don't see anything that would configure this for what we are using it for in this tutorial. This is the one that I am using.
http://unixetc.co.uk/2014/11/04/enable-outgoing-mail-on-raspberry-pi/

2 Likes