HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: alpha23 on December 07, 2014, 09:32:43 PM

Title: SMtpClient.Send Exception
Post by: alpha23 on December 07, 2014, 09:32:43 PM
I'm receiving an exception similar to the following (from http://www.homegenie.it/forum/index.php?topic=320.0 (http://www.homegenie.it/forum/index.php?topic=320.0))

2014-08-22T06:55:45.4124340-07:00       HomeAutomation.HomeGenie.Automation    NetHelper        Message could not be sent.      Exception.StackTrace      at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) [0x00000] in <filename unknown>:0
  at HomeGenie.Automation.Scripting.NetHelper.SendMessage (System.String from, System.String recipients, System.String subject, System.String messageText) [0x00000] in <filename unknown>:0

smtp port is 25, no SSL.  I do not see any logs that will help resolve. 

To verify that the system could send emails, I tested with ssmtp and it works fine.

Thoughts on how to fix the above exception?
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on December 31, 2014, 11:58:17 PM
I am having the same issue as well.
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 03, 2015, 04:55:49 AM
I am still having this issue.  I just rebuilt the Pi today and re installed everything fresh and fully updated.  I have tried smtp.gmail.com, smtp-mail.outlook.com, and a secure SMTP server I run at work, and all give me

"2015-01-02T22:44:25.7565540-05:00   HomeAutomation.HomeGenie.Automation   NetHelper   Message could not be sent.   Exception.StackTrace     at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) [0x00000] in <filename unknown>:0 "

I have tested using telnet and am able to send from the pi.
(http://meganssmith.wordpress.com/2015/01/01/testing-email-part-two-the-telnet-ssl-way/ (http://meganssmith.wordpress.com/2015/01/01/testing-email-part-two-the-telnet-ssl-way/))
(http://meganssmith.wordpress.com/2015/01/01/testing-email-part-one-the-open-ssl-way/ (http://meganssmith.wordpress.com/2015/01/01/testing-email-part-one-the-open-ssl-way/))

I been looking for a way to trigger a test email in HG besides tripping the alarm, but I have yet to find it.  I have tried changing PWs to more "simple" PWs thinking maybe HG is having an issue parsing special characters, but that did not help.  Any ideas?
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 03, 2015, 08:47:59 PM
So to add to this.  I created a testing app based off the code in the security app.

Code: [Select]
// send email
      //
      var subject = "HomeGenie Test emails by Lady Sapphy";
      var messagetext = "Test email sent from the Lady Sapphy test app";
      var recipients = "<my email addresses>";
      if (recipients != "")
        {
          Program.RunAsyncTask(()=>{
      Net.SendMessage(recipients, subject, messagetext);
            });
        }
        //
I run this from the program editor and it worked (using gmail as the SMTP server)
I trigger the security app, and still no emails
I add this app to the " Program to run when triggered" and it the app runs and sends email, but the emails from security does not send  ???
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 04, 2015, 10:33:13 PM
I just wanted to say that with the update I got today, it seems to be working now!!!!!
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 04, 2015, 10:43:44 PM
I may have spoke too soon.  It worked once  :'(
Title: Re: SMtpClient.Send Exception
Post by: Gene on January 04, 2015, 11:31:00 PM
There are no changes regarding the NetHelper/Smtp in the latest update.
Btw I think the problem is about SSL certificates. To install them run the command:

Code: [Select]
mozroots --import --ask-remove --machine

Since HG runs as root user I am not sure if this command should also be run with sudo as well.

Cheers,
g.
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 05, 2015, 02:05:40 AM
I don't think the issue is with the core HG code, I think it is with the security call.  I am using almost the same code in a test app and it works every time without fail.  The only change between security code and my code is I declare the vars explicitly where the security app is pulling them in from other places.
Title: Re: SMtpClient.Send Exception
Post by: Gene on January 05, 2015, 02:16:21 AM
Did you enable/configure the Messaging and Social->E-Mail Account app?
The security alarm app takes settings from there.

Cheers,
g.
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 05, 2015, 02:40:15 AM
yes I did, my test app I posted above use the same call to get the SMTP info.
Title: Re: SMtpClient.Send Exception
Post by: Gene on January 05, 2015, 02:42:10 AM
Please add a issue to github then, so I'll be checking this out.
https://github.com/genielabs/HomeGenie/issues
g.
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 05, 2015, 02:47:05 AM
Done
Title: Re: SMtpClient.Send Exception
Post by: LadySapphy on January 13, 2015, 05:13:38 AM
I think I might of found my issue. I am still testing, but I am 4 for 4 in testing now. It seems that I overlooked something in the install, my locale was set to en_gb instead of en_EN.  I changed mine to en_US (did not see en_EN).  Since that change, testing as worked every time although sometimes it takes over 10 min to send the email.