[RELEASE] SendGrid Email notification plugin

I threw this together based of @ogiewon's Pushover driver for SendGrid. It's pretty basic but it gets the job done if you only need to send <100 messages/day and don't want to run your own SMTP server and don't have access to an app to do push notifications. You should also be able to email your SMS address with it, but I haven't tested that.

Requirements

  • This requires a SendGrid account; their free plan offers 100 emails/day
  • You will also have to verify an email address to “send as”; if you use a free mail provider (@gmail, @yahoo, etc), there may be delivery issues because of DMARC - this works better if you own your own domain, do your own DNS, and can make changes to your domain to ensure delivery. Luckily, Sengrid gives you a way to see all emails you've sent so you can determine if this will work before you really need it.
  • Create an API Key by going here and selecting CURL. Give it a name, create the key, then copy that key to the installation below. Leave this page open and go down to the installation then send a test. You should see it reflected in this page.

Installation

  • Easiest install method is via Hubitat Package Manager (HPM)

OR

FAQ

  1. What our my other options instead of this app:
  2. It says in the debug logs that the message was queued but I haven't seen it come through.
    • Check your SPAM folder.
    • Check the SendGrid Activity area to see if the notification was received.
  3. I don't want to pay for SendGrid.
    • Neither do I. If you get it via GCP it is FREE for up to 12,000 emails a month.

Updates
26AUG2020: Added option for multiple recipients, option to BCC recipients, and option to send as high priority.
03SEP2020: Removed/replaced special chars & new lines in the message

16 Likes

Worked flawlessly.

Had an old Sendgrid account with a generous free tier. Now I can make use of it. @brianwilson thank you for this driver. :slight_smile:

1 Like

Mine is working as well and MUCH needed... many thanks to @brianwilson for providing this driver.

@brianwilson:
Thanks very much ... works great....

Since more than 1 person is using this, I added some new options: multiple recipients, BCC option and option to send message with high priority.

5 Likes

It just gets better and better :slight_smile:

3 Likes

Going to set this up to email texts to my family, who are not interested in installing the HE app. Thank you very much

Question:
I'm getting this in my logs for the past few days:


My device is set up as follows:

Also, using it manually from the device page seems to work with no issues.

That's an older version. Can you load up the driver and click import again? It should pull the latest version. Any idea if you know what notifications trigger that error? It might be a notification with something like quotes in it.

EDIT: New version out that escapes messages with newlines & special chars if you're having issues.

@brianwilson Brian:
Another question:
Why do I get these error messages:

Does it happen every time, or just certain messages?

It appears to happen every time. Here is a manual test from the Device page:

I also tried it from the page to my email , and I also got that same error message.
Unauthorized.

I will check on SendGrid and see what I can find out there.

Aha:
A possible explanation:
image

Just a shout out to @brianwilson for a stellar mail solution; works like a charm.

I tried the other mail solutions (HEMail & Sendmail) and they never worked.
Also tried the version where you run a local SMTP server on a Pi, and while that did work, I just didn't like it - I couldn't change the from e-mail address.

Oddball question: Upon RECEIVING mail successfully via SendGrid, in this example a gmail account, the FROM shows as "hubitat"; see image below
image

While this is NOT incorrect, I would like to show it with an uppercase "H", similar to
image

The limitation doesn't appear to be a) a web broser issue or b) g-mail in this case, but rather either the driver, or SendGrid itself.

Is this anything you can fix?

Thanks
J

1 Like

Hi @GatVlieg

I think what you are looking for can be achieved from the device preference page itself. :slight_smile:

Under 'Sender Address', save the field as Hubitat@yourdomain.com. Depending on how you've saved the sender address (uppercase or lowercase or mix) in the preference, gmail should show the 'From' username exactly the same way.

However, if you want to have a different 'First Name and Last Name' to the email address, then @brianwilson may have to make some changes in his driver.

For example:

From: Hubitat Notifications
Email: no-reply@yourdomain.com

If not this, @GatVlieg, it may be related to the email address you originally validated with SendGrid.

@sujit & @brianwilson

Thanks for your replies.
I can confirm that the suggestion by @sujit works; by capitalizing the Sender Address it appears Capitalized in G-Mail. (can't speak for other e-mail apps)

@brianwilson, is it possible to implement the example used by @sujit?
image

I took a look at the options available to me using a free account in SendGrid, and I could not spot anything that stood out.

TIA
J

1 Like

Added from name as an option (Defaults to Hubitat) as mentioned by @sujit.

3 Likes

Works like a charm!

That was freaking fast !

Also added this to Hubitat Package Manager. You’ll need to run the match option if you’ve already got this driver installed, assuming you want it to be managed by HPM.