Please login or register.

Login with username, password and session length
Pages: [1] 2 3

Author Topic: raspberry pi 4 and email  (Read 6759 times)

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
raspberry pi 4 and email
« on: January 27, 2021, 12:51:40 PM »

Does anyone know why HG no longer likes this simple program:

var subject = "test email";
var messagetext = "HG Test Email";
var recipients = "mike@kihgere.com";
Net.SendMessage( recipients, subject, messagetext );

   if (Net.SendMessage(recipients, subject, messagetext) == true)
      Program.Notify("E-Mail Notification", "SUCCESS! Notification sent.");
   else Program.Notify("E-Mail Notification", "ERROR: Notification **NOT** sent.");


It faults when run with this error message:   "the specified string is not in the form required for an email address"

I have replaced each variable in the Net.SendMessage command with the actual values with and without quotes, and same errors.

It seems to be something to do with the new pi4 as this always worked on my zero w cards.


Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: raspberry pi 4 and email
« Reply #1 on: January 27, 2021, 03:49:11 PM »

I recently spent hours working with petera figuring this issue out.  This testing included building many sd images with various tweaks to setup (HG version, mobo version, mobo packages, different smtp providers, etc, etc).  I would test something that worked for petera and find no joy on my end. After nearly giving up, it appears that the issue is a fairly poor implementation of the email setup program.

In my case I found that the settings I entered into the tool were not always taking.  In the end, I was able to get email working by making sure that the settings were correct with my email provider first. Second (and this is the critical part) make sure that after you type out the field contents hit 'enter'. If you skip this step HG does not update the parameter and the email service will fail.

Also to be safe I would recommend waiting to modify the next field until the progress spinner is working. I dont know what HG will do if you modify the settings while a previous one is in work. I suspect strongly this was a critical part of my issues.

Gene needs to update the code to fix this, but he's been unable to review/implement several other bug fixes in months so i dont think this will likely be on his priority list.
« Last Edit: January 27, 2021, 03:50:56 PM by bkenobi »
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: raspberry pi 4 and email
« Reply #2 on: January 27, 2021, 04:09:22 PM »

1) In my case I found that the settings I entered into the tool were not always taking. 
2) In the end, I was able to get email working by making sure that the settings were correct with my email provider first.
3) Second (and this is the critical part) make sure that after you type out the field contents hit 'enter'. If you skip this step HG does not update the parameter and the email service will fail.
4) Also to be safe I would recommend waiting to modify the next field until the progress spinner is working. I dont know what HG will do if you modify the settings while a previous one is in work. I suspect strongly this was a critical part of my issues.

Thank you for your comments!  I too have found all of what you say true. 

1) I have resorted in the past to the same method;  make new SD card images so I can add new fresh data to 'options' in PID#142 email account!  I found once I had a working set of data, I could  cut and paste the email section out of systemconfig.xml to force it to 'take.'
1a)  My next attempt is going to be to modify his #142 program to NOT test for changes before writing the data...

2) Ditto here, but that is not the new issue with these pi4's...  I am making a second pi for my location across town and it too has the same issue:  the HG command "Net.SendMessage()" is failing with erro stating the email address is not formed correctly.  Nothing to do with the #142 email sned option data I am thinking...   Unless...

3&4) Ditto!  I agree if you do not hit enter after a change, or wait for THAT change to take effect, it probably does not make the change.  I have learned to wait on both.

Thanks for your comments.   I do not understand why Net.SendMessage() command worked on pi zero w but does not on pi4...   But I will re investigate the #142 email data program in case the issue is there instead.
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: raspberry pi 4 and email
« Reply #3 on: January 27, 2021, 05:44:34 PM »

Don't bother changing the email setup program as you have suggested. That tool is designed to take the values and apply them to HG in the correct place. If you remove the test for change, it won't do anything when a change is made. The tool should be rewritten such that a submit button applies all changes at once IMO. I considered that but simply waiting is likely the best we can do. Gene could surely fix the issue but he seems occupied with other pursuits currently.

I realized I had not submitted the issue so I submitted #428 for posterity.

https://github.com/genielabs/HomeGenie/issues/428

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750
Re: raspberry pi 4 and email
« Reply #4 on: January 27, 2021, 06:16:09 PM »

Don't bother changing the email setup program as you have suggested. That tool is designed to take the values and apply them to HG in the correct place. If you remove the test for change, it won't do anything when a change is made. The tool should be rewritten such that a submit button applies all changes at once IMO. I considered that but simply waiting is likely the best we can do. Gene could surely fix the issue but he seems occupied with other pursuits currently.

I realized I had not submitted the issue so I submitted #428 for posterity.

https://github.com/genielabs/HomeGenie/issues/428

Ah this little nugget again.  rofl it's like schwarzenegger in Terminator "I'll be back" . Nothing to do with Pi4 or any other RPI version. As you mentioned at one stage I thought of dropping across the pond with my SD card to pop it into your RPI as I thought you or I were going mad  rofl rofl

I'm not sure if the problem relates only to this program or to email notifications in general. So I'll assume it's email notifications in general.

If the program Email Account Details is exported from HG, then delete it from HG and reimport into HG I wonder is it still holding the original program ID number. If so does it still show the Email Account information. If not this would be the time to enter the correct account details slowly line by line hitting the Enter key after each line is completed right down to the check box SSL which will be the last Enter press to make. Save the details and retry the program Test Email.

I'm curious to see what the log reports when trying to run this program.

I strongly suggest that any user export a vanilla copy of any configuration file before attempting to configure HG for the first time. Saves all this trouble later.
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: raspberry pi 4 and email
« Reply #5 on: January 28, 2021, 10:34:39 AM »

Don't bother changing the email setup program as you have suggested. That tool is designed to take the values and apply them to HG in the correct place. If you remove the test for change, it won't do anything when a change is made. The tool should be rewritten such that a submit button applies all changes at once IMO. I considered that but simply waiting is likely the best we can do. Gene could surely fix the issue but he seems occupied with other pursuits currently.

I realized I had not submitted the issue so I submitted #428 for posterity.

https://github.com/genielabs/HomeGenie/issues/428

Studying the program closely, I see it iruns in background and watches for what it considers a change, so I cannot simply remove the IF change save else dont around it.  I think I will experiment with adding a new program that only runs when I push the run action, and will then not miss the changes.  I can watch the HG .xml file to verify it working or not.
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: raspberry pi 4 and email
« Reply #6 on: January 28, 2021, 10:41:27 AM »

I do not believe this is the wrong email information entered issue of the past but rather a NEW issue due to buster on pi4.  It is NOT telling me it could not send email, it is telling me the FORMAT of the email address itself is no good - totally different issue than the past.  Here is the log proving this I believe:

/api/HomeAutomation.HomeGenie/Automation/Programs.Run/1001/null [OPEN]
2021-01-28 10:36:56.6808 Info HomeAutomation.HomeGenie.Automation   1001   Automation Program   Runtime.Error   
2021-01-28 10:36:56.8003 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1001/ [OPEN]
2021-01-28 10:36:56.8003 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1001/ [CLOSED AFTER 0.003 seconds]
2021-01-28 10:36:57.2283 Info HomeAutomation.HomeGenie.Automation   1001   Automation Program   Program.Status   Running
2021-01-28 10:36:57.2431 Trace SendMessage: called for recipients mike@kilroywashere.com
2021-01-28 10:36:57.2431 Info HomeAutomation.HomeGenie.Automation   1001   Automation Program   Program.Status   Idle
2021-01-28 10:36:57.2431 Error HomeAutomation.HomeGenie   Service.Utility.RunAsyncTask   The specified string is not in the form required for an e-mail address.   Exception.StackTrace     at System.Net.Mail.MailAddressParser.ReadCfwsAndThrowIfIncomplete (System.String data, System.Int32 index) [0x00010] in <a9a08e39ba304bd0a84c49bd158dfc02>:0
  at System.Net.Mail.MailAddressParser.ParseDomain (System.String data, System.Int32& index) [0x00047] in <a9a08e39ba304bd0a84c49bd158dfc02>:0
  at System.Net.Mail.MailAddressParser.ParseAddress (System.String data, System.Boolean expectMultipleAddresses, System.Int32& index) [0x0002c] in <a9a08e39ba304bd0a84c49bd158dfc02>:0
  at System.Net.Mail.MailAddressParser.ParseAddress (System.String data) [0x00009] in <a9a08e39ba304bd0a84c49bd158dfc02>:0
  at System.Net.Mail.MailAddress..ctor (System.String address, System.String displayName, System.Text.Encoding displayNameEncoding) [0x000ef] in <a9a08e39ba304bd0a84c49bd158dfc02>:0
  at System.Net.Mail.MailAddress..ctor (System.String address) [0x00000] in <a9a08e39ba304bd0a84c49bd158dfc02>:0
  at HomeGenie.Automation.Scripting.NetHelper.SendMessage (System.String from, System.String recipients, System.String subject, System.String messageText) [0x00087] in <4d5ba25d4d9e46c9aca8997cbd305edf>:0
  at HomeGenie.Automation.Scripting.NetHelper.SendMessage (System.String recipients, System.String subject, System.String messageText) [0x0005a] in <4d5ba25d4d9e46c9aca8997cbd305edf>:0
  at HomeGenie.Automation.Scripting.ScriptingInstance+<RunCode>c__AnonStorey0.<>m__0 () [0x0000c] in <dcc0d41010ba484a8c0292919e6a880d>:0
  at HomeGenie.Service.Utility+<>c__DisplayClass24_0.<RunAsyncTask>b__0 ()
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: raspberry pi 4 and email
« Reply #7 on: January 28, 2021, 10:53:32 AM »

last post was program 1001 that just does nothing when run other than write in log wrong string form for email address.  does not even get the IF THEN of sent or failed to print HG message.

THIS log is for program 1000:  siilar test email send but this one fails and HG reports wrong email address format in message window, in log, and in program page when I tell it to run.  Does not say which line number failed tho. 

2021-01-28 10:47:40.7627 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Automation/Programs.Run/1000/null [OPEN]
2021-01-28 10:47:40.7627 Info HomeAutomation.HomeGenie.Automation   1000   Automation Program   Runtime.Error   
2021-01-28 10:47:40.8620 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1000/ [OPEN]
2021-01-28 10:47:40.8723 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1000/ [CLOSED AFTER 0.01 seconds]
2021-01-28 10:47:41.3009 Info HomeAutomation.HomeGenie.Automation   1000   Automation Program   Program.Status   Running
2021-01-28 10:47:41.3171 Trace SendMessage: called for recipients mike@kilroywashere.com
2021-01-28 10:47:41.3171 Error Error while running program 1000
2021-01-28 10:47:41.3171 Info HomeAutomation.HomeGenie.Automation   1000   Automation Program   Runtime.Error   CR: The specified string is not in the form required for an e-mail address.
2021-01-28 10:47:41.3306 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Automation/Programs.Run/1000/null [CLOSED AFTER 0.568 seconds]
2021-01-28 10:47:41.4058 Info HomeAutomation.HomeGenie.Automation   1000   Automation Program   Program.Status   Disabled
2021-01-28 10:47:41.4967 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1000/ [OPEN]
2021-01-28 10:47:41.4967 Info WebServiceGateway   192.168.7.129   HTTP   GET   200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/1000/ [CLOSED AFTER 0.002 seconds]
2021-01-28 10:47:41.5043 Info HomeAutomation.HomeGenie.Automation   1000   Automation Program   Program.Status   Stopped
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: raspberry pi 4 and email
« Reply #8 on: January 28, 2021, 11:00:09 AM »

I believe I can confirm the email sender program #142 is not the culprit as I replaced the whole email settings section of systemconfig.xml with a known good section from my past working zw units.  Error is the same so I am sure it is not related to bad data in the 142 program. 
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: raspberry pi 4 and email
« Reply #9 on: January 28, 2021, 11:01:33 AM »

Perhaps there is a way to use a plain vanilla stand alone email program on the pi, send it message from HG,  and run it from HG when wanted?
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 282
  • Posts: 10497
  • I don't work for X10, I use it successfuly!
Re: raspberry pi 4 and email
« Reply #10 on: January 28, 2021, 11:53:29 AM »

Perhaps there is a way to use a plain vanilla stand alone email program on the pi, send it message from HG,  and run it from HG when wanted?
I believe this is what some are doing for other things that have become outdated and nolonger work.
 Check for a python route to do your emailing from command line. Then pass your message from HG to the python script.
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: raspberry pi 4 and email
« Reply #11 on: January 31, 2021, 03:10:04 PM »

I tried copying python script for sending email into a program but it did not take - gave many errors.

surely there is a way to make the SendMessage work again in pi4!    ugh!
Logged

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750
Re: raspberry pi 4 and email
« Reply #12 on: January 31, 2021, 04:12:34 PM »

Do a screen cap of your Email Account settings and paste it here. You’re being told what the issue is in the log.

I’ve no doubt that your edited Email Account settings didn’t take effect as you were advised before. You’re going around in circles here getting nowhere quickly. You can blame it on your RPI4 if it makes you happier but that isn’t the reason it won’t work.

Rather than waste hours more fiddling with this I suggest making a fresh install of HG without any restored backups and concentrate on this one issue to prove your theory.
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: raspberry pi 4 and email
« Reply #13 on: January 31, 2021, 04:58:18 PM »

@petera - Mike doesnt like the solution I provided. Maybe you will have a better chance convincing him. We spent weeks working on this very issue so you'd think both you and I would be able to help. Oh well.

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750
Re: raspberry pi 4 and email
« Reply #14 on: January 31, 2021, 05:08:18 PM »

@petera - Mike doesnt like the solution I provided. Maybe you will have a better chance convincing him. We spent weeks working on this very issue so you'd think both you and I would be able to help. Oh well.

Absolutely. I did ask for a log a while back and it turned up eventually. It clearly states what the problem is

CR: The specified string is not in the form required for an e-mail address.

Now one would assume that you check the Email Account settings to see what the problem is. Then you realize it looks correct but did that change you made previously actually take. Probably not and there we are. Back to the solution you provided. QED.

Logged
Pages: [1] 2 3
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.