X10 Community Forum

📱🖥️PiX10Hub => 🏥Help and Trouble Shooting => Topic started by: mike on February 24, 2019, 12:16:12 PM

Title: HG email not sending
Post by: mike on February 24, 2019, 12:16:12 PM
So I assume I have the known 'certificate' issue in mono that prevents email from sending from HG.

I have latest HG (.37), supposed proper mono (ver 5.4.0.201), have done update/upgrade, but still no email sending.  HG log reports:

2019-02-24 11:52:07.1672 Trace SendMessage: going to send email System.Net.Mail.MailMessage using mailService 'smtp.gmail.com', port '465', credentials System.Net.NetworkCredential, using SSL = True

then:

2019-02-24 11:52:17.4956 Trace SendMessage: error sending email {0}
2019-02-24 11:52:17.5003 Error System.Net.Mail.SmtpException: Message could not be sent. ---> System.IO.IOException: Connection closed
  at System.Net.Mail.SmtpClient.Read () [0x000bd] in <8a8abae728c244359683ef777047ab9e>:0
  at System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) [0x00000] in <8a8abae728c244359683ef777047ab9e>:0
  at System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message) [0x00050] in <8a8abae728c244359683ef777047ab9e>:0
  at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) [0x00084] in <8a8abae728c244359683ef777047ab9e>:0
   --- End of inner exception stack trace ---
  at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) [0x0009f] in <8a8abae728c244359683ef777047ab9e>:0
  at HomeGenie.Automation.Scripting.NetHelper.SendMessage (System.String from, System.String recipients, System.String subject, System.String messageText) [0x003f1] in <b08d74f9b7fb4c85b616d2d9beee8275>:0
2019-02-24 11:52:17.5211 Error HomeAutomation.HomeGenie.Automation
  at HomeGenie.Automation.Scripting.NetHelper.SendMessage (System.String from, System.String recipients, System.String subject, System.String messageText) [0x003f1] in <b08d74f9b7fb4c85b616d2d9beee8275>:0
2019-02-24 11:52:17.5225 Trace SendMessage: disposing smtpClient
2019-02-24 11:52:17.5264 Trace SendMessage: called for recipients mike@kilroywashere.com
2019-02-24 11:52:17.5310 Trace SendMessage: getting smtpSyncLock
2019-02-24 11:52:17.5323 Trace SendMessage: got smtpSyncLock
2019-02-24 11:52:17.5378 Trace SendMessage: going to send email System.Net.Mail.MailMessage using mailService 'smtp.gmail.com', port '465', credentials System.Net.NetworkCredential, using SSL = True

I assume this is the certificate issue in mono so often spoken about? 

I have tried non gmail account for my smtp sender and same thing.

I try the certificate update command:

pi@raspberrypi:~ $ sudo apt-get install ca-certificates-mono
Reading package lists... Done
Building dependency tree
Reading state information... Done
ca-certificates-mono is already the newest version (5.4.0.201-0xamarin10+raspbian9b1).
ca-certificates-mono set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

So that does not do it.

ANY CLUES WHERE I SHOULD LOOK NEXT TO GET WORKING EMAIL?
Title: Re: HG email not sending
Post by: mike on February 24, 2019, 01:14:07 PM
More searching found this at old.homegenie.club
 Topic: Errors after 447->493 update - help please  (Read 3731 times)

After mono install:
1. cert-sync /etc/pki/tls/certs/ca-bundle.crt
2. certmgr -ssl -m smtps://smtp.gmail.com:465 (and say "y" to all questions)
3. restart homegenie

Email Account program in homegenie settings:
1. E-Mail address: <email>@gmail.com
2. SMTP Mail Server address: smtp.gmail.com
3. SMTP username: <email>@gmail.com
4. SMTP password: <app specific password since I'm using 2 step verification>
5. SMTP Mail Server port: 587
6. SMTP Mail Server use SSL: TRUE


So tried it:

pi@raspberrypi:~ $ cert-sync /etc/pki/tls/certs/ca-bundle.crt
Unknown option or file not found '/etc/pki/tls/certs/ca-bundle.crt'.
Mono Certificate Store Sync - version 5.4.0.201
Populate Mono certificate store from a concatenated list of certificates.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

Usage: cert-sync [--quiet] [--user] system-ca-bundle.crt
Where system-ca-bundle.crt is in PEM format

So that command doesn't work...

next:

pi@raspberrypi:~ $ certmgr -ssl -m smtps://smtp.gmail.com:465
Mono Certificate Manager - version 5.4.0.201
Manage X.509 certificates and CRL from stores.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.


X.509 Certificate v3
   Issued from: OU=GlobalSign Root CA - R2, O=GlobalSign, CN=GlobalSign
   Issued to:   C=US, O=Google Trust Services, CN=Google Internet Authority G3
   Valid from:  15/06/2017 00:00:42
   Valid until: 15/12/2021 00:00:42
   *** WARNING: Certificate signature is INVALID ***
Import this certificate into the CA store ?y
Access to the machine '' certificate store has been denied.


OK, step 2 didn't work...

I am no further along yet to making email work in HG...
Title: Re: HG email not sending
Post by: mike on February 24, 2019, 01:18:17 PM
maybe sudo:

pi@raspberrypi:~ $ sudo certmgr -ssl -m smtps://smtp.gmail.com:465
Mono Certificate Manager - version 5.4.0.201
Manage X.509 certificates and CRL from stores.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.


X.509 Certificate v3
   Issued from: OU=GlobalSign Root CA - R2, O=GlobalSign, CN=GlobalSign
   Issued to:   C=US, O=Google Trust Services, CN=Google Internet Authority G3
   Valid from:  15/06/2017 00:00:42
   Valid until: 15/12/2021 00:00:42
   *** WARNING: Certificate signature is INVALID ***
Import this certificate into the CA store ?y

X.509 Certificate v3
   Issued from: C=US, O=Google Trust Services, CN=Google Internet Authority G3
   Issued to:   C=US, S=California, L=Mountain View, O=Google LLC, CN=smtp.gmail.com
   Valid from:  29/01/2019 14:59:18
   Valid until: 23/04/2019 14:59:00
Import this certificate into the AddressBook store ?y

2 certificates added to the stores.
Title: Re: HG email not sending
Post by: mike on February 24, 2019, 02:23:59 PM
Tried yahoo account & pi@raspberrypi:~ $ sudo certmgr -ssl -m smtps://smtp.mail.yahoo.com:465


still no go. 
Title: Re: HG email not sending
Post by: racerfern on February 24, 2019, 02:58:48 PM
This has been an on going issue for some Homeseer users as well. I believe it has something to do with two factor authorization. I gave up trying to use Gmail with homeseer and now use an email address from my ISP provider, Optimum.

You might want to do a search on the homeseer forum.
Title: Re: HG email not sending
Post by: mike on February 24, 2019, 03:13:53 PM
Thanks racerfern.  I have tried gmail, yahoo and my own server.  All fail with the same wierd error.
Title: Re: HG email not sending
Post by: racerfern on February 24, 2019, 04:34:52 PM
Lots of discussions about this for win, mac and pi.

Googled, "Access to the machine certificate store has been denied. raspberry pi"

Lots of suggestions, not sure if I actually saw a solution.
Title: Re: HG email not sending
Post by: petera on February 24, 2019, 04:38:15 PM
You don't need to add certs to Mono since v5x. Change your port no to 587 and make sure you have ticked the SSL option in HG. Use the spacebar to make sure the tick shows in the box.

Be careful when installing things like certs in Raspbian. You need to do that as a super user (sudo). Unless otherwise mentioned most of the Linux instructions in the old HG forum do not refer to Raspbian so they tend not to include the sudo command in front of the install instructions.
Title: Re: HG email not sending
Post by: brobin on February 24, 2019, 05:03:39 PM
I have no idea if this will be helpful but as time went on and email services became more secure, my Stargate could no longer send emails because it couldn't handle SSL and there was no upgrade.  My solution was to create a free account at https://www.smtp2go.com/ and send emails using port 2525 without SSL. As I said, this may have nothing to do with the issue at hand but might be worth a look. The free outgoing mail allowance is quite generous at 500 per month.
Title: Re: HG email not sending
Post by: mike on February 25, 2019, 03:44:11 PM
Thanks brobin!  I too have a non-ssl email account and it too does not work so my issue must be something else.  I have made a new SD card with latest tuicemen SD image;  I will try it soon oon another pi I have around here.
Title: Re: HG email not sending
Post by: mike on February 25, 2019, 03:45:23 PM
Thanks petera for your comment.  No one else seems to have known mono 5.0 and great no longer need certmgr.  I keep learning a tidbit at a time.
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 01:45:29 PM
@mike, I admire you for all the time you've spent on this. Myself I would have uninstalled HG and started fresh long ago.
I made a script that removes the current version of HG and then installs 1.2-stable.30 some time ago.

It may help you as it will put a fresh install of HG on your pi so you can start a new without the need for a new image. You only need to have a HG backup file to restore to. This will put HG on port 80 unless you have something else running on that port like HA-Bridge. If you think you can use this let me know and I'll post a copy. ;)
 >!
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 02:11:14 PM
Please post, thank you.  Yes, I will try it.  And I DID start fresh - downloaded your latest x10user image, burned it, installed it on a separate pi running on my system.  It too will not send - same issue:  HG remembers the FIRST email Account info entered and never again overwrites it, no matter how many times the options screen is changed. 

As HG is potentially open source, if I knew how to download the HG source code I would attempt to decode where the program fault is that does not allow rewriting this info.

Starting from ground 0 again and doing exactly the same thing again is not worth it for me as I am sure I would get the same result.

Starting from a script that only screws up HG is worth a try.

Thank you.
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 02:25:46 PM
well the script doesn't screw up HG it removes all instances of HG on your Pi then rebuild it installing 1.2-stable.30
I believe I had read you did get email working at one point but either adding your backup or reimaging you lost it.
You can download the current version code of HG by clicking on the green "Clone or download" button right of the GitHub page (https://github.com/genielabs/HomeGenie)
In any case the Revert script is attached download it and rename it to "Revert" place it in the home/pi folder.
to utilize and run it from putty be sure your in the Home/pi folder and type sh Revert
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 02:51:16 PM
yes, it worked ONCE - UNTIL I REBOOTED THE PI.

Tried Revert:

pi@X10Hub:~ $ sh Revert
homegenie.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable homegenie
rm: cannot remove '/etc/systemd/system/homegenie.service': No such file or directory
dpkg: error: dpkg status database is locked by another process
Revert: 10: Revert: Syntax error: "else" unexpected (expecting "then")



EDIT:  There is no homegenie.service in that directory here...  This is your latest non beta SD image
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 02:54:40 PM
ok error may be the result of just not finding a file. I thought this was the version I had used but I may have another copy somewhere let me check. Check to see if HG is still installed or if it is now on version 1.2-stable.30
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 02:56:56 PM
searching for homegenie.service...

I found it so far here:

var/run/systemd/generator.late   

still searching for another cc...
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:00:40 PM
ok, changed to that directory in your Revert.  Goes further before crashing:

pi@X10Hub:~ $ sh Revert
homegenie.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable homegenie
rm: cannot remove '/var/run/systemd/generator.late/system/homegenie.service': No such file or directory
(Reading database ... 52406 files and directories currently installed.)
Removing homegenie (1.2-stable.26) ...
[ ok ] Stopping homegenie (via systemctl): homegenie.service.
dpkg: warning: while removing homegenie, directory '/usr/local/bin/homegenie/lib/mig' not empty so not removed
dpkg: warning: while removing homegenie, directory '/usr/local/bin/homegenie/programs' not empty so not removed
dpkg: warning: while removing homegenie, directory '/usr/local/bin/homegenie/html/images/wallpapers' not empty so not removed
Revert: 10: Revert: Syntax error: "else" unexpected (expecting "then")
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:02:30 PM
my bad;  missed a subdirectory name...  trying again
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:05:20 PM
pi@X10Hub:~ $ sh Revert
Warning: homegenie.service changed on disk. Run 'systemctl daemon-reload' to reload units.
rm: cannot remove '/var/run/systemd/generator.late/homegenie.service': No such file or directory
dpkg: warning: ignoring request to remove homegenie which isn't installed
Revert: 10: Revert: Syntax error: "else" unexpected (expecting "then")


hmmm..   homegenie.service is there...
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:06:58 PM
not my day.

pi@X10Hub:~ $ systemctl daemon-reload
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to reload daemon: Access denied
pi@X10Hub:~ $ systemctl daemon-reload
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to reload daemon: Access denied
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:08:27 PM
ok error may be the result of just not finding a file. I thought this was the version I had used but I may have another copy somewhere let me check. Check to see if HG is still installed or if it is now on version 1.2-stable.30

BTW, after not getting anywhere with allowing me to change options (email account data), I tried updating to latest, so this HG is on stable.38 if that matters.

And I just checked, and this pi is still happily running HG on my system.
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 03:08:45 PM
Ok looks like that Revert file was from my beta test stop running it. you most likely have HG removed check to see.
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 03:09:40 PM
HG version your reverting from makes no difference.
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:12:27 PM
I assume it was still running as it switched pages from dashboard to the funny lites page;  may have been in cache tho as now with a refresh HG seems gone, yet.
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:13:15 PM
so now I go find your posts of how to install HG?  nevewrmind.  just looked at Revert text;  I can run the stuff there now.

will let you kow.  THANKS!
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:17:51 PM
wierd:

pi@X10Hub:~ $ sudo rm -r /usr/local/bin/homegenie
rm: cannot remove '/usr/local/bin/homegenie': No such file or directory

I am staring at that directory in WinSCP right now...

again, nevermind;  winSCP is not good at refreshing.  directory is gone.   one to reinstalling...
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 03:20:07 PM
why do you have owner as 2000?
where are you seeing that?
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 03:25:43 PM
I think part of the issue may have been the script was made in Windows  as it was on my Windows PC and it may have some hidden characters which throws errors. at least you've got HG uninstalled and you can reinstall I'll work at fixing the script.
 >!
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:31:07 PM
no, your script is fine:

#!bin/bash
#this reverts HG back to the homegenie_1.2-stable.34 build
cd
sudo systemctl stop homegenie.service
sudo systemctl disable homegenie.service
sudo rm -r /var/run/systemd/generator.late/homegenie.service
sudo dpkg --remove homegenie
if [ -f homegenie/HomeGenie.exe ] then
sudo rm -r homegenie
else
sudo rm -r /usr/local/bin/homegenie
fi
sudo wget https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.34/homegenie_1.2-stable.34_all.deb
sudo gdebi homegenie_1.2-stable.34_all.deb
echo " HomeGenie 1.2-stable.34 is now installed please reboot"


I just tried to reinstall and failed miserably:

pi@X10Hub:/usr/local/bin $ pi@X10Hub:~ $ fi
-bash: pi@X10Hub:~: command not found
pi@X10Hub:/usr/local/bin $ -bash: syntax error near unexpected token `fi'
> pi@X10Hub:~ $ cd /usr
> pi@X10Hub:/usr $ cd local/bin
> pi@X10Hub:/usr/local/bin $ dir
> pi@X10Hub:/usr/local/bin $ cd ..
> pi@X10Hub:/usr/local $ chown pi:pi bin
> chown: changing ownership of 'bin': Operation not permitted
> pi@X10Hub:/usr/local $ sudo chown pi:pi bin
> pi@X10Hub:/usr/local $ cd bin
> pi@X10Hub:/usr/local/bin $ sh Revert-reinstall_HG
> --2019-03-11 15:23:53--  https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.34/homegenie_1.2-stable.34_all.deb%0D
> Resolving github.com (github.com)... 192.30.253.113, 192.30.253.112
> Connecting to github.com (github.com)|192.30.253.113|:443... connected.
> HTTP request sent, awaiting response... 404 Not Found
> 20SCP19-03-11 15:23:53 ERROR 404: Not Found.
>
> gdebi error, file not found: homegenie_1.2-stable.34_all.deb
>  HomeGenie 1.2-stable.34 is now installed please reboot
> : not foundstall_HG: 4: Revert-reinstall_HG:
> pi@X10Hub:/usr/local/bin $
>

Not sure what a "fi" command is...
winSCP would not allow me to copy my program to this usr/local/bin dir as it was owned by root, so I changed that, copied my new program Revert-reinstall_HG to that directory:

sudo wget https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.34/homegenie_1.2-stable.34_all.deb
sudo gdebi homegenie_1.2-stable.34_all.deb
echo " HomeGenie 1.2-stable.34 is now installed please reboot"

running it gave Result that was less than pleasing:

pi@X10Hub:/usr/local/bin $ sh Revert-reinstall_HG
--2019-03-11 15:30:52--  https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.34/homegenie_1.2-stable.34_all.deb%0D
Resolving github.com (github.com)... 192.30.253.113, 192.30.253.112
Connecting to github.com (github.com)|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-03-11 15:30:52 ERROR 404: Not Found.

gdebi error, file not found: homegenie_1.2-stable.34_all.deb
 HomeGenie 1.2-stable.34 is now installed please reboot
: not foundstall_HG: 4: Revert-reinstall_HG:


Quit for now.
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 03:39:38 PM
fi closes the if statement the install is meant to be done from home/pi not /usr/local/bin that's why things whet side ways
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 03:49:31 PM
Oh.  OK.  Well I am a gluten for punishment;  I am going to run all 3 install commands, just one at a time.

Starting in directory usr/local/bin...

sudo wget https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.34/homegenie_1.2-stable.34_all.deb

is installed as I write this.   Put a bunch of nonsense in the directory, all 0 file lengths...

oh well, on to 2nd command,       sudo gdebi homegenie_1.2-stable.34_all.deb

It is working on it...

Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 03:53:12 PM
you are a gluten for punishment  rofl
sudo wget https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.34/homegenie_1.2-stable.34_all.deb should only put one file in the folder, that being "homegenie_1.2-stable.34_all.deb"
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 04:11:18 PM
holy crap.  holy holy....

new install.  used the BAD option data for gmail that I THOUGHT worked once:  port 587 PLUS SSL.

HG just sent me an email!
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 04:12:35 PM
What do I need to do to make this set of data STICK?  make a backup of course, but  if I do a reboot of pi right now I totally expect to loose these settings and loose email capability....
Title: Re: HG email not sending
Post by: mike on March 11, 2019, 04:17:32 PM
you are a gluten for punishment  rofl
sudo wget https://github.com/genielabs/HomeGenie/releases/download/v1.2-stable.34/homegenie_1.2-stable.34_all.deb should only put one file in the folder, that being "homegenie_1.2-stable.34_all.deb"

FYI.  NOTE the owner 2000 (default if not root on ALL files on your last SD image)
Title: Re: HG email not sending
Post by: Tuicemen on March 11, 2019, 05:36:51 PM
Do a back up but also do a service restart from inside HG this will insure settings are saved. Don't get impatient and reboot, if anything just refresh your browser.
Since you didn't have any email settings entered prior it has nothing to revert to.
However a backup of your old settings could mess with that by re-introducing the issue that was preventing a change prior.
The User 200 may be related to how WinSCP shows owner ship.
I've never used that the HG install on the image was done exactly as you just did so I'm at a loss as to what it means.
Title: Re: HG email not sending
Post by: mike on March 12, 2019, 11:44:48 AM
I want to thank everyone for your continued help!    My HG is emailing finally!  Yahoo!  Copying the account data over did not fix it by itself after restarts and reboots.  BUT UPGRADING HG FROM STABLE.37 TO STABLE.39 DID FIX IT!
Title: Re: HG email not sending
Post by: Tuicemen on March 12, 2019, 11:51:46 AM
Glad to see you finally got it working!
 >!
Title: Re: HG email not sending
Post by: bkenobi on March 12, 2019, 12:13:08 PM
FWIW, it appears that if you use an image for too long, support will be dropped.  My install was based on Wheezy and some repositories dropped support years ago.  Be aware that if this image is successful (never needs touching for a very long time), you may have issues running the update/upgrade at some point since you are basing the image on Stretch which will eventually lose support too.  Just FYI...