Email Notifications Driver using Node/sendmail on a PI

OK. I decided to give this another try. I think I'm further than before.

I can send an email from a browser using "http://localhost:port/mail.php" and that works, so I think sendmail is up and running.

Now, from Hubitat, I'm still getting problems.

I've set up the virtual device as follows:

DoNetStuff Email URL: http://ip:port/email
Service: smtps (587)
Server: blank
From: my_gmail_account
To: another_account
Subject: Test1

From the DOS shell, I see the following:

from/to/subject/text are all there just as expected from the hubitat virtual device

Then I get this error:

Error: getaddrinfo ENOTFOUND null
at GetAddrInfoReqWrap.onlookup [as oncomplete] {dns.js:66:26}

errno: -3000,
code: 'ECONNECTION' ,
syscall: 'getaddrinfo',
command: 'CONN'


Is there anyone that could give me a couple of pointers? Seems like I'm one step shy of this working

Whats your eml_config.js file look like?

module.exports = {
        "someemail@email.com": {authuser: "authuser1@email.com", authpwd: "auth password1"}
        ,"another@email.com": {authuser: "authuser2@someserver.com", authpwd: "auth password2"}
        ,"authuser3@gmail.com": {authuser: "authuser3@gmail.com", authpwd: "auth password3"}
};

module.exports = {
"someemail@email.com": {authuser: "authuser1@email.com", authpwd: "auth password1"}
,"another@email.com": {authuser: "authuser2@someserver.com", authpwd: "auth password2"}
,"authuser3@gmail.com": {authuser: "authuser3@gmail.com", authpwd: "auth password3"}
,"my_gmail@gmail.com": {authuser: "my_gmail@gmail.com", authpwd: "my_password"}
};

You can get rid of the other entries... but I don't think thats your issue. It doesn't like your mail server connection... mmm if you are using gmail why not select the "gmail" service type rather than "smtps (587)"?

module.exports = {
	"my_gmail@gmail.com": {authuser: "my_gmail@gmail.com", authpwd: "my_password"}
};

Apologies in advance - it's been a while since I've looked at this!

You could also go with the unsecured "sendmail" service type as well and that should match your device settings.

OK. Got it to work!!!!

Trick (key) was to use "google" as the service in Hubitat.

Thank you for the assistance erktrek....most helpful

1 Like

I do have one last question.

For each send (I'm sending to my cellphone using their email to SMS), I get a different sender. It looks like "1410200432" then "1410100533" then "1410200433".

Any idea how to get texts so that they are always from the same sender?

UPDATE: I found the issue. I was sending SMS. When I changed it to MMS, the text always shows from the same person.

That seems strange it should be the gmail account. In your driver what do you have the "From:" preference set to?

In the Hubitat virtual device, I have my gmail account.

It appears that using SMS will generate these strange numbers; changing each time a text (email) is sent. However, when I use MMS, the text shows it is from my gmail account (always).

So, SMS gives me one unique receipt for every text
MMS gives me one recipient with every text from that contact

How did you get MMS instead of SMS?

You simply email to a different server. See below:

US Cell Providers "Email to Txt" Email Addresses

========================================================
AT&T: {cell number}[at]txt.att.net (SMS), {cell number}[at]mms.att.net (MMS)
T-Mobile: {cell number}[at]tmomail.net (SMS & MMS)
Verizon: {cell number}[at]vtext.com (SMS), {cell number}[at]vzwpix.com (MMS)
Sprint: {cell number}[at]messaging.sprintpcs.com (SMS), {cell number}[at]pm.sprint.com (MMS)
XFinity Mobile: {cell number}[at]vtext.com (SMS), {cell number}[at]mypixmessages.com (MMS)
Virgin Mobile: {cell number}[at]vmobl.com (SMS), {cell number}[at]vmpix.com (MMS)
Tracfone: {cell number}[at]mmst5.tracfone.com (MMS)
Metro PCS: {cell number}[at]mymetropcs.com (SMS & MMS)
Boost Mobile: {cell number}[at]sms.myboostmobile.com (SMS), {cell number}[at]myboostmobile.com (MMS)
Cricket: {cell number}[at]sms.cricketwireless.net (SMS), {cell number}[at]mms.cricketwireless.net (MMS)
Republic Wireless: {cell number}[at]text.republicwireless.com (SMS)
Google Fi (Project Fi): {cell number}[at]msg.fi.google.com (SMS & MMS)
U.S. Cellular: {cell number}[at]email.uscc.net (SMS), {cell number}[at]mms.uscc.net (MMS)
Ting: {cell number}[at]message.ting.com
Consumer Cellular: {cell number}[at]mailmymobile.net
C-Spire: {cell number}[at]cspire1.com
Page Plus: {cell number}[at]vtext.com

4 Likes

That is great info thanks!!!

1 Like

Anyone seeing delays in receiving text via AT&T (sent to <MOBILE_NUMBER>@mms.att.net)? I am sending an email and text - the email gets there right away but the text is delayed by up to 2 hours.

I'm bringing this thread back to life - hopefully to help anyone else whose notifications using this driver stopped working, like mine did.

When I setup sendmail, I created a dummy Gmail account and used the account option to permit "Less Secure App" access to sendmail from my SBC using the dummy account. As of May 30th, 2022, Google has turned off less secure app access. Instead, they require the use of app specific passwords, which is more secure anyway. Here are the steps needed:

  1. Login to the Google account.
  2. Turn on 2-factor authentication. This is needed to generate app-specific passwords
  3. Generate an app specific password for your sendmail needs and copy down the 16-character password.
  4. On your SBC (most often RPi), go to the directory /etc/mail/authinfo
  5. Edit the sendmail authentication file (I called mine gmail-auth) and replace the less secure cleartext password with the 16-character app-specific password.
  6. Recreate the hash database using the command (assuming your authentication file is called gmail-auth):
    makemap hash gmail-auth < gmail-auth
  7. Stop and restart sendmail

Took less than 5 minutes to get it up and running again after I realized that Google had turned off the "less secure app access" option.

3 Likes

I just noticed that I wasn't getting any emails/texts.

Thanks @aaiyar - I will try this.

2 Likes

@ashok:
I tried this, but apparently it's not working, my trace shows:

050 454 4.7.0 Too many login attempts, please try again later. u3-20020a372e03000000b006a323e60e29sm17015075qkh.135 - gsmtp

Could perhaps the problem be that in the sendmail.mc file, there is a line:

define(SMART_HOST',[smtp.gmail.com]')dnl
define(RELAY_MAILER_ARGS', TCP $h 587')dnl
define(ESMTP_MAILER_ARGS', TCP $h 587')dnl
define(confAUTH_OPTIONS', A p')dnl
TRUST_AUTH_MECH(EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl define(confAUTH_MECHANISMS', EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(authinfo',`hash -o /etc/mail/authinfo/gmail-auth.db')dnl

Is the word "PLAIN" still appropriate?

You should not have to edit sendmail.mc, or recreate a new sendmail.cf using m4.

From the error that you have posted, the MTA would appear not to be using the new 16-character app password.

Just to confirm:

  1. You edited /etc/mail/authinfo/gmail-auth?
  2. You re-created /etc/mail/authinfo/gmail-auth.db using the command (as root) makemap hash gmail-auth < gmail-auth?
  3. sendmail was restarted?

Can we confirm the usernames and permissions on the relevant files?

Here are mine:

-rw------- 1 root  smmsp    68 Jun  7 15:51 gmail-auth
-rw-r----- 1 smmta smmsp 12288 Jun  7 15:51 gmail-auth.db

And /etc/mail/authinfo should be:

drwx--S--- 2 root smmsp 4096 Jun 7 16:02 authinfo

Also, the structure of /etc/mail/authinfo/gmail-auth should be something like:

AuthInfo: "U:root" "I:your_username@gmail.com" "P:16_character_app_passwd"

BTW, FWIW, my sendmail.mc is identical to yours:

dnl # Default Mailer setup
#
MAILER_DEFINITIONS
define(`SMART_HOST',`[smtp.gmail.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo/gmail-auth.db')dnl
MAILER(`local')dnl
MAILER(`smtp')dnl
1 Like

Confirming:

  1. edited /etc/mail/authinfo/gmail-auth
  2. recreated *.db using hash command
  3. sendmail was stopped and then started

Usernames & permissions:
image

gmail-auth is the same as you have it, except that I use "pi" instead of "root"

Does the user "pi" have permission to mail?

OK.
Well, I will change it to "root" and see if that make a difference.