Please login or register.

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

Author Topic: Email Script Help  (Read 13702 times)

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #30 on: February 20, 2019, 11:28:41 AM »

Update:  I thought the HG program update ran generic update/upgrade, but watching closely this time I see it did not.  So issue is likely as Bkenobi says.  I wrote the following before remembering his comment on mono certificate comment the other day, and now reminder again (thank you).  I will do that next.

--------------------

So email not sending but both your program and mine are commanding HG to send.  I will try a different email to send from than gmail next as I cannot understand what the 'stack trace' error is. 

Log shows:

{"Title":"E-Mail Notification","Message":"ERROR: Notification **NOT** sent."}

and specifically:   

2019-02-20 11:12:34.9637 Trace SendMessage: called for recipients myemail.com         
2019-02-20 11:12:34.9701 Trace SendMessage: getting smtpSyncLock         
2019-02-20 11:12:34.9747 Trace SendMessage: got smtpSyncLock         
2019-02-20 11:12:35.2938 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 later:

2019-02-20 11:12:47.2021 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-20 11:12:47.4257 Error HomeAutomation.HomeGenie.Automation   NetHelper   Message could not be sent.   Exception.StackTrace     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-20 11:12:47.4601 Trace SendMessage: disposing smtpClient            





« Last Edit: February 20, 2019, 11:53:11 AM by Tuicemen »
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #31 on: February 20, 2019, 11:52:31 AM »

OK, I understand but I'm not sure the Tamper reports quicker then an open.
However I've never played with that enough to be sure.

Guess you are right;  I just know with my trest DS10 I can open and close quickly and HG module shows tamper right away and then may not ever show OPEN because I closed it quickly...  But the log proved me wrong;  I just checked and it shows tamper AND also OPEN on adjacent lines.  So good to know that even a loose wire on the reed switch terminal that comes and goes should be seen by HG.
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: Email Script Help
« Reply #32 on: February 20, 2019, 11:55:51 AM »

Modified you r log file to Hide your Email Address.
I thought they were the same , Good to know
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #33 on: February 20, 2019, 12:01:28 PM »

thanks.   update did not fix sending email.  1/2 way thru upgrade and it did not fix sending either...  will try again in an hour or so when it is done with upgrade.  If no go, I will change to another non gmail account to send from. 
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2082
Re: Email Script Help
« Reply #34 on: February 20, 2019, 02:06:33 PM »

I email through yahoo but I have used gmail at some point.  Mine is not working again so I need to run update/upgrade myself.  As I said before, this should really be added to a cron event IMO.  I haven't done it, but maybe I'll get to it some day.

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #35 on: February 20, 2019, 02:11:54 PM »

I finished update and upgrade.  Still no email sent - says stack error... 

Tried changing to my own server smtp and it does same thing.

tried a reboot of pi in case that was required, no change.

So the HGx programs WORK, they call:

2019-02-20 13:22:54.4055 Trace SendMessage: going to send email System.Net.Mail.MailMessage using mailService 'smtp.gmail.com', port '465', credentials System.Net.NetworkCredential, using SSL = True

fail on this:

2019-02-20 13:23:05.4538 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 ---

and report this:    2019-02-20 13:23:05.4500 Trace SendMessage: error sending email {0}
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: Email Script Help
« Reply #36 on: February 20, 2019, 02:26:16 PM »

I email through yahoo but I have used gmail at some point.  Mine is not working again so I need to run update/upgrade myself.  As I said before, this should really be added to a cron event IMO.  I haven't done it, but maybe I'll get to it some day.
I use Hotmail myself and the weird thing is I've not did a Update/Upgrade since Sept or later and am still getting email notifications from my off grid place ::) :'  So I should expect a failure soon :o I thought moving up from Mono 4 fixed that issue. ???
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #37 on: February 20, 2019, 02:35:05 PM »

I will try a yahoo account next, but I am thinking the issue is something else...  the error seems to be more HG can't write the variable into its email routine?

Error System.Net.Mail.SmtpException: Message could not be sent. ---> System.ArgumentException: Stream was not writable.
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: Email Script Help
« Reply #38 on: February 20, 2019, 02:49:34 PM »

Yep that will do it.
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: Email Script Help
« Reply #39 on: February 20, 2019, 03:26:07 PM »

This thread has inspired me to work on a Smart_E-mailer which once done should make a lot of my email Alert Programs obsolete. ::) :'  Currently it works for most modules in HG I have. However I don't have the Arm/Disarm or Night sends coded as yet as I'm still playing with those implementations.  I'm thinking of removing the send when Disarm option and if Armed is selected it only sends then otherwise always unless night is checked. It also only emails when the configured module status value changes to 1

Hope I don't confuse myself with all the ifs and elses  rofl
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #40 on: February 20, 2019, 03:32:52 PM »

wow!  And here I am with another 7 hours into trying to get basic emailing to run on HG!  I suppose if you accomplish this thing I will have to start over with your latest image that includes it.  I just shudder at the thought of going to a new image SD card since I KNOW HAbridge will be broken again and require another 20 hours of fiddling to get it to run again! 
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: Email Script Help
« Reply #41 on: February 20, 2019, 03:42:14 PM »

You can always backup your settings of HA-Bridge configuration and devices and copy them to your PC to later put back on the PI. That's what backups are for, to save hours of fiddling if a re-build is needed.
Actually you could copy the whole HA-Bridge folder to your PC then move it back. However that would require some File attribute changes I believe.


I have to take a break from the emailer. :( it didn't take long for the Ifs & Elses to make me dizzy  rofl
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #42 on: February 20, 2019, 03:46:38 PM »

I have TWO email writing programs, mine & yours...   I did NOT update yours - it is identical to what you sent me, using the obsolete

Program.AddInputField("Email.Recipients", "", "Comma separated list of recipients e-mails that will get a test e-mail");
Program.AddInputField("Email.Message", "HomeGenie Notification.", "E-mail message");
Program.AddInputField("Email.Subject", "HomeGenie Alert Warning", "E-mail subject");
var subject = Program.InputField("Email.Subject").Value;
var recipients = Program.InputField("Email.Recipients").Value;
var messageText = Program.InputField("Email.Message").Value;


I think this is why you get the error when compiling but it seems to still work.

I DID update mine to the new commands for above

Program.AddOption("Sensor", "garage", "Sensors to alert on (comma separated)", "text")
Program.AddOption("Email.Recipients", "a@a.com", "Email recipients", "text")
if(Program.Option("Sensor").Value.Contains(module.Instance.Name))
var recipients = Program.Option("Email.Recipients").Value
Logged

mike

  • Hero Member
  • *****
  • Helpful Post Rating: 14
  • Posts: 1057
Re: Email Script Help
« Reply #43 on: February 20, 2019, 03:51:16 PM »

dizzy, ha! 

Ya, I am good at using WinSCP & putty to CHOWN pi:pi directory -R!  I can copy and put back like that;  but IIRC the last time I did that it did not work - seems the SD card name changed from mine to yours and THAT stopped it in its tracks...  So I assume if I start over I will find some similar issue to stop me...

I make HG backups like 20 times per day when working on stuff like this...   Think I am at 20 so far today!

I am going to try sending this next, too long today so probably tomorrow:

from:
bool SendMessage   (   string    recipients,
string    subject,
string    messageText
)      
Sends an E-Mail.

Returns
true, if message was sent, false otherwise.
Parameters
recipients   Message recipients.
subject   Message subject.
messageText   Message text.

I will change one of the sends from:

 Net.SendMessage(recipients, subject, messagetext)

to:

 Net.SendMessage(me@my.com, test subject, hi Bob)

If that doesn't work then:

 Net.SendMessage("me@my.com", "test subject", "hi Bob")

Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: Email Script Help
« Reply #44 on: February 20, 2019, 06:05:45 PM »

I don't get errors just warnings, there is a difference. ;)
I believe the HG code hasn't been fully updated to use the new suggested methods. ::)
If you change the Program.AddInputField to Program.AddOption in the Start up code but leave the Program.AddInputField in the Program code the emails still get sent. I can use either method. :o
The error warnings all point to the Startup code.

I have no Program.AddInputField entry anywhere in my new code but I still get 6 warnings about outdated code even though  what it points to uses the new suggested method. ::) :' I can change the code to use a Program.AddInputField in the Program code but then I still get 6 errors not 7  B:(.
Logged
Please Read Topic:
General Forum Etiquette
Before you post!
Pages: 1 2 [3] 4 5
 

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