[BETA RELEASE] HEmail - Simple Email Notification Device Driver, no RPi needed

So after experimenting with a few different options I've settled on HEmail and it works great.

I installed Synology Mail Server on my NAS and configured it to be an SMTP Relay (this is crazy simple to do) to my MS Outlook account. HEmail then uses it to email notifications to my Gmail account.

I tried using Gmail and Yahoo as SMTP relays but they won't allow it and I didn't bother trying iCloud.

Synology Mail Server Config:

HEmail Config:
Email User = Synology User Name
Email Password = Synology User Password

@erktrek Is it possible to add some sort of queuing to your driver or retry function? I'm occasionally finding emails just aren't being sent at all and there's nothing on my Mail Relay to indicate an attempt to send an email was even made.

I know the notifications I'm using work, because they also use push App notifications (from the same Notification rule) which work every time.

So the driver is pretty simplistic - establish a telnet connection and dump what is passed. A thought would be adding some sort of delay or retry and beefing up error trapping.

I have not really messed with the code since I started using Node-RED which has it's own email node that works with everything.

2 Likes

Ah, I think the issue is notifications sent close together. The first one always works, but the 2nd one fails if an email notification is still in progress.

1 Like

Any chance you could add a delay function that waits for say 1 second after the IP email is being sent before sending the next one?

PS, I have no plans to use NR, it's very cool but now I have my head around RM I just dont see a need for it.

So each send is a separate thread I think. Best I can do is introduce a random delay before sending. Will look into..

1 Like

Cheers.

1 Like

Here is my issue. I have an internal Email server (Postfix) running on a linux box. My email notification all go through the postfix and work great as I have the Postfix box relaying to Gmail using a secure connection. So basically I just need this to send and email to my postfix server with only these fields:

  • SMTP Server
  • From Address
  • Port

This postfix server is at my house and behind a firewall. I use it for all notifications within my network. It only sends. All my apps that I have running or servers only require those 3 fields.

How can I make this work? I tried setting the other fields to false, but it still doesn't send.

This is how you setup postfix to relay to Gmail for those interested.

https://www.linode.com/docs/guides/configure-postfix-to-send-mail-using-gmail-and-google-apps-on-debian-or-ubuntu/

1 Like

That's cool thanks for the link. I am doing exactly the same except I run my own mail server (postfix as well!) in a dmz but that will come in handy I think.

Have you looked at @kahn-hubitat's sendmail? He's been actively developing his version so that might be something to consider.

I am using Node-RED for my rules etc - it has built in email support so I can securely send and notify based on HE events.

1 Like

I'm running a DMZ also. I looked at Kahn's app and it says no local server needed. I'm really looking for something that stays inside and let Postfix securely send the email through Gmail. I really thought this app would work. I think it's close I just don't know code or I'd fix it for my use.

I use sendmail as a relay. And my outgoing email is sent via Gmail - I have a specific Google username just for my Hubitat notification email. I had to decrease account security to get this to work. Specifically, turn on "Less secure app access".

1 Like

Once you do that are you sure it's only turned on just for that one Gmail accoun? Would not want that enabled across regular personal accounts...

2 Likes

Is there any way to use some sort of global/process variable as a type of "lock"?

If it was set, that meant something else was sending--causing other threads to wait until they could get the lock variable?

It wouldn't likely be 100%, unless there is some sort of thread-safe locking in HE to check and set that variable in an atomic process.

Yes, I think there is.. something to look at maybe... mmmm

1 Like

I just added a semaphore lock to the seqSend function. It's on github now. Have not really tested it all that much.

1 Like

I second this idea. My ISP offers non-SSL SMTP but does not support authentication over plaintext.

Can you please remove the requirement of providing a username and password?

[Edit]
I got it working with Sendmail - Send email and text notifications, (notification device) no local server needed
[/Edit]

Sure! Let me look into it.

I just added a quick bypass let me know if this works for you...

E.

here are the changes i made recently to get mms working correctly on
AT&t so we could get texts in one thread.. thought you'd want to know..

  def msgData = "${state.EmailBody}"
	        def emlBody = ""
	        def emlSubject = ""
            def emlDateTime = new Date().format('EEE, dd MMM YYYY H:mm:ss Z',location.timeZone)
               
            def String idP1 = now()
            def String idP2 = java.util.UUID.randomUUID().toString().replaceAll('-', '')
            def String msgId = '<' + idP2 + "." + idP1 + "@2LGKSendmailV2>"
               
          if(msgData.substring(0,1) == "{") {
	             	
		        def slurper = new groovy.json.JsonSlurper()
		        def result = slurper.parseText(msgData)
		        emlBody = result.Body
		        emlSubject = (result.Subject != null ? result.Subject : "")
	        } else {
	           	emlBody = msgData
	        	emlSubject = (Subject != null ? "${Subject}" : "")
	        }   
        
	   
              def sndMsg =[
                  "MAIL FROM: <${From}>"
                , "RCPT TO: <${To}>"
        		, "DATA"
                , "From: ${From}"
                , "To: ${To}"
                , "Date: ${emlDateTime}"
                , "Message-ID: ${msgId}"
                , "Subject: ${emlSubject}"  
                , "MIME-Version: 1.0"
                , 'Content-Type: text/plain; charset="us-ascii"'
                , "Content-Transfer-Encoding: quoted-printable\r\n"
                , ""
        		, "${emlBody}"
        		, ""
        		, "."
	        	, "quit"
            ]
2 Likes

Wow that looks like it was "fun" to figure out.. thank you.

1 Like