HomeGenie Forum

General Category => Troubleshooting and Support => Topic started by: kiwi799 on November 16, 2014, 06:47:01 PM

Title: mail notification not received
Post by: kiwi799 on November 16, 2014, 06:47:01 PM
hello, I am struggling to make mail notification on my HG, but I did not succeeded for the moment. I follow this topic "http://www.homegenie.it/forum/index.php?topic=223.0", but it is not working for me.

I have HG r421 on Ubuntu server v14.
I setup my Email Account with Gmail or Yahoo.fr account but did not receive any mail
Code: [Select]
1. E-Mail address
<email>@gmail.com
2. SMTP Mail Server address
smtp.gmail.com
3. SMTP username (optional)
<email>@gmail.com
4. SMTP password (optional)
<account password>
5. SMTP Mail Server port
587
6. SMTP Mail Server use SSL (TRUE or FALSE)
TRUE

For my test, I create a C# program with below in program code
Code: [Select]
// CSharp Automation Program : send an email to test the mail settings
var subject = "test email";
var messagetext = "HG Test Email";
var recipients = "########@gmail.com";
Net.SendMessage( recipients, subject, messagetext );

Here is my trigger code:
Code: [Select]
if (Modules.InDomain("HomeAutomation.ZWave").WithAddress("5").IsOn)
{
  return true;
}
else
{
  return false;
}

When I switch on my "Zwave 5" light, I don't receive email.
So I installed an SMTP server on another computer, activated SMTP log on this server. Then send sucessfully an email by telnet. The SMTP session is logged in the SMTP server log.

I changed my Email account to use my lcoal SMTP server.
Code: [Select]
Email.Sender = "[email protected]"
Email.SmtpPassword = "password"
Email.SmtpPort = "25"
Email.SmtpServer = "192.168.77.82"
Email.SmtpUserName = "user1"
Email.SmtpUseSsl = "FALSE"
I changed my C# program with below in program code
Code: [Select]
// CSharp Automation Program : send an email to test the mail settings
var subject = "test email";
var messagetext = "HG Test Email";
var recipients = "[email protected]";
Net.SendMessage( recipients, subject, messagetext );
Now when I switch on my "Zwave 5" light, nothing is logged in the SMTP log. So this means that HG does not try to connect to my SMTP server 192.168.77.82.

I also added a module to my Zwave group so as there is a button which activate my program. When I click on it, it should send the email. But this also does not make my HG connect to my SMTP server.

Can someone help please ? Did I miss something in my HG settings ?
Title: Re: mail notification not received
Post by: mvdarend on November 17, 2014, 07:18:49 AM
Is the program firing? You can try adding a notification to make sure that the program is run:

Code: [Select]
Program.Notify("Debug", "Program called, now attempting to send email.");
Title: Re: mail notification not received
Post by: kiwi799 on November 20, 2014, 11:31:43 PM
Thanks mvdarend for the idea of program.notify.
I added one program.notify before and one after. Then the first tries only show the program.notify before the Net.SendMessage( recipients, subject, messagetext ).
So I clear all the program code and start from scratch, then it works with my local SMTP server :)
Then I tried again with Gmail or Yahoo.fr, but it was unsucessfull, I can see both program.notify. But did not receive email.
Finally I try with another email provider "free.fr", the one for my internet access and it does work  ;D
So now my mail notification works perfectly.
Thanks for your help.
Title: Re: mail notification not received
Post by: Bobpick on November 23, 2014, 02:15:19 AM
I am also running into issues with sending emails. I've set up Gmail according to the information I've found on this board.

I found this in my log:
2014-11-22T20:11:59.9192038-05:00   HomeAutomation.HomeGenie.Automation   NetHelper   Failure sending mail.   Exception.StackTrace      at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at HomeGenie.Automation.Scripting.NetHelper.SendMessage(String from, String recipients, String subject, String messageText)

Any suggestion?
Title: Re: mail notification not received
Post by: jshan on November 23, 2014, 04:04:21 AM
I could not get GMail to work.  I ended up using yahoo mail with success.
Title: Re: mail notification not received
Post by: Gene on November 23, 2014, 03:46:58 PM
The problem with GMail could be the missing ssl certificates.
These can be installed using mozroots command:
Code: [Select]
sudo apt-get install mono-devel
mozroots --import --ask-remove --machine
certmgr -ssl smtps://smtp.gmail.com:465

Reference: http://stackoverflow.com/questions/9801224/smtpclient-with-gmail (http://stackoverflow.com/questions/9801224/smtpclient-with-gmail)

Cheers,
g.
Title: Re: mail notification not received
Post by: Bobpick on November 23, 2014, 06:21:46 PM
Gene,

I'm using Windows 8.1.  Those commands look like Linux commands.
Title: Re: mail notification not received
Post by: Gene on November 23, 2014, 06:35:06 PM
I'm not sure but this looks like a similar solution for Windows:

http://www.arcencus.nl/Blogs/tabid/105/EntryID/39/Default.aspx (http://www.arcencus.nl/Blogs/tabid/105/EntryID/39/Default.aspx)

g.
Title: Re: mail notification not received
Post by: Bobpick on November 23, 2014, 07:10:21 PM
I'll give it a shot.
Title: Re: mail notification not received
Post by: sourmush on November 24, 2014, 01:26:50 AM
Using port 587 instead of 465 will work for gmail.
Title: Re: mail notification not received
Post by: nvuono on October 12, 2015, 04:37:03 AM
Quote
The problem with GMail could be the missing ssl certificates.
These can be installed using mozroots command:
Code: [Select]
sudo apt-get install mono-devel
mozroots --import --ask-remove --machine
certmgr -ssl smtps://smtp.gmail.com:465

Reference: [url]http://stackoverflow.com/questions/9801224/smtpclient-with-gmail[/url] ([url]http://stackoverflow.com/questions/9801224/smtpclient-with-gmail[/url])

Cheers,
g.



This would not work for me until I took the additional steps of running:
Code: [Select]
mozroots --import --ask-remove --machine
certmgr -ssl smtps://smtp.gmail.com:465[quote author=Gene

Reference: http://www.mono-project.com/docs/faq/security/ (http://www.mono-project.com/docs/faq/security/)]
Title: Re: mail notification not received
Post by: bkenobi on October 16, 2015, 05:02:24 PM
I tried these steps with yahoo and it didn't work.  All steps seemed to work but the resulting attempts to have HG send messages didn't end up in my inbox.  I guess I can try using my gmail as the send account if that works.
Title: Re: mail notification not received
Post by: bkenobi on October 18, 2015, 06:00:52 PM
I also tried switching over to using my gmail account and it also did not go through.  The only thing I can think of is trying to send the email manually in a Linux console to see what if any error messages I receive.
Title: Re: mail notification not received
Post by: nolio on October 21, 2015, 11:23:30 PM
I just try on my side. With the Gene command line
Code: [Select]
sudo apt-get install mono-devel
mozroots --import --ask-remove --machine
certmgr -ssl smtps://smtp.gmail.com:465
and the de-sactivation on that link :
https://www.google.com/settings/security/lesssecureapps (https://www.google.com/settings/security/lesssecureapps)
It works !! :)
Title: Re: mail notification not received
Post by: bkenobi on October 22, 2015, 06:20:31 AM
Has something changed in the SendMessage function?  I used to be able to send a message with the following:
Code: [Select]
Net.SendMessage( "[email protected]", "email test", "test email from HomeGenie" );However, now when I run that code, I get an error in mono:
Code: [Select]
2015-10-21 21:13:03.9927 Error 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
Title: Re: mail notification not received
Post by: nolio on October 22, 2015, 07:16:04 PM
Similar problem , but i didn't take a look at the log.
I use this :
Code: [Select]
// CSharp Automation Program : send an email to test the mail settings
var subject = "test email";
var messagetext = "HG Test Email";
var recipients = "########@gmail.com";
Net.SendMessage( recipients, subject, messagetext );

And it works better ... I don't search why ;)
Title: Re: mail notification not received
Post by: bkenobi on October 23, 2015, 05:51:28 AM
Well, I'm still stuck.

I used openssl to connect to smtp.mail.yahoo.com and manually send a test email...SUCCESS!  I had to use a app specific password, but that worked just fine.

I then tried to connect using HG and I don't get an indication that the password was used, so I believe that the issue I'm having is the error I posted earlier.  I tried using the same code that nolio posted, but it gives me the same error.  I know HG can send messages since it was working earlier this year, but it most definitely does not work today.
Title: Re: mail notification not received
Post by: petediscrete on October 23, 2015, 09:32:44 PM
Have you upgraded recently. I tested the email send notification on the RPI an hour ago and all seems fine.
Title: Re: mail notification not received
Post by: bkenobi on October 23, 2015, 10:59:48 PM
I'm on the current version of HG.  Unless you mean running update on the RPi, in which case I did that last week or so when I ran Gene's Linux commands to set up the certs.  I suppose I could back up my settings and reinstall HG just to make sure I have everything up to date.
Title: Re: mail notification not received
Post by: bkenobi on October 26, 2015, 04:38:55 AM
I updated to HG 498 and did not install my backup initially.  With the default setup, I updated the email setup APP to set up my yahoo!mail and added a new APP to perform a test email.  With this configuration, I get an error in the HG web log and no email.  I restored my backup and no change.
Title: Re: mail notification not received
Post by: VuSaKe on June 24, 2016, 10:41:50 AM
Hi,

I'm having trouble with the mail notification. I've got HG r525 updated from r522 and it doesn´t matter what email configuration i use i receive the following error:

"2016-06-24 10:32:25.5707 Error HomeAutomation.HomeGenie.Automation   NetHelper   530 5.7.0 Must issue a STARTTLS command first."
"   Exception.StackTrace     at System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) [0x00000] in <filename unknown>:0 "
  at System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message) [0x00000] in <filename unknown>:0
  at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) [0x00000] in <filename unknown>:0


I´ve tried with gmail, yahoo and hotmail and always the same.

Searching in the forum i´ve found 2 possible solutions

sudo apt-get install ca-certificates-mono  --> the package doesn´t exist
----------------------------------------------
sudo apt-get install mono-devel
mozroots --import --ask-remove --machine
certmgr -ssl smtps://smtp.gmail.com:465

When executing "mozroots --import --ask-remove --machine" this is what i receive:

Mozilla Roots Importer - version 3.2.8.0
Download and import trusted root certificates from Mozilla's MXR.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

Downloading from 'http://mxr.mozilla.org/seamonkey/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1'... (http://mxr.mozilla.org/seamonkey/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1'...)
Couldn't retrieve the file using the supplied information.


I´ve also tried to update mono after reading some posts in the forum, but homegenie starts to fail

Any ideas?
Title: Re: mail notification not received
Post by: Gene on June 24, 2016, 10:51:10 AM
It's a bug in HG >= r522.
The fix is to place at line 230 of the NetHelper.cs class:

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Automation/Scripting/NetHelper.cs#L230

Code: [Select]
                        if (spSmtpUseSsl != null && (spSmtpUseSsl.Value.ToLower() == "true" || spSmtpUseSsl.Value.ToLower() == "on" || spSmtpUseSsl.DecimalValue == 1))

I will make this fix available in the next release.

g.
Title: Re: mail notification not received
Post by: VuSaKe on June 24, 2016, 12:26:58 PM
Thanks for the quick answer :)

Is it a file a can modify easily? i couldn´t find it......  :-[
Title: Re: mail notification not received
Post by: lfiocco on June 30, 2016, 06:39:33 PM
does 525 have this fix. if not how do i fix it myself?
Title: Re: mail notification not received
Post by: petediscrete on June 30, 2016, 09:28:44 PM
Just upgraded from 5.19 to 5.25 and email notification working fine
Title: Re: mail notification not received
Post by: lfiocco on July 01, 2016, 02:22:45 AM
i back tracked to 499, still no go. here is what i get

2016-06-30 20:15:56.2458 Info RaspberryPi.Gpio  GPIO26  Virtual Module  Status.Level    1
2016-06-30 20:15:56.3962 Info HomeAutomation.HomeGenie.Automation       90      Automation Program      HomeGenie.SecurityTriggered     1
2016-06-30 20:15:56.3973 Debug Event propagation halted by automation program 'Security Alarm System' (90) (Name=Status.Level, OldValue=1, NewValue=1)
2016-06-30 20:15:56.5107 Info WebServiceGateway 192.168.10.31   HTTP    GET     200 /api/HomeAutomation.HomeGenie/Config/Modules.Get/HomeAutomation.HomeGenie.Automation/90/
2016-06-30 20:15:57.2635 Error HomeAutomation.HomeGenie.Automation      NetHelper       Message could not be sent.      Exception.StackTrace      at System.Net.Mail.SmtpClient.Send (System.Net.Mai$
  at HomeGenie.Automation.Scripting.NetHelper.SendMessage (System.String from, System.String recipients, System.String subject, System.String messageText) [0x00000] in <filename unknown>:0
2016-06-30 20:15:58.7101 Info RaspberryPi.Gpio  GPIO26  Virtual Module  Status.Level    0
2016-06-30 20:15:59.6150 Info RaspberryPi.Gpio  GPIO26  Virtual Module  Status.Level    1

this gets triggered after gpio goes high.

i am using Gmail.
I have an IP camera, it also uses the same account and it works. i disabled the app program less security feature in google

did not realized this was going to be so hard to figure out. please help
Title: Re: mail notification not received
Post by: petediscrete on January 10, 2017, 12:35:46 AM
I know its been a while since a reply was made on this post but a reference was made to rc525 not sending email.My email notifications stopped on the 10th December 2016.No changes were made to my setup in HG nor were updates made my Raspberry Pi running Raspbian Wheezy.I've tried everything I can possibly think of. I can send email to my Gmail account via a terminal session using SSMTP so I know the client is working and all the relevant updated certificates are in order.

I can see no changes that were made by Google that may cause this problem.HG is reporting that mail was sent but I receive nothing.

Would anyone have any further suggestions that may help here.
Title: Re: mail notification not received
Post by: bkenobi on January 10, 2017, 05:06:20 PM
I never got gmail working after google changed things a year or two back.  I have been using yahoo and it works fine.  I just tested and my email is working correctly as of now.

I am running r501 now (I had 519 but a restore took me back to 501 apparently).  I haven't updated anything email related since I published the RPi tutorial linked earlier in this thread.
Title: Re: mail notification not received
Post by: nolio on January 10, 2017, 09:01:37 PM
petediscrete, did you try that ?
https://support.google.com/accounts/answer/6010255?hl=en
Title: Re: mail notification not received
Post by: bkenobi on January 11, 2017, 01:07:24 AM
Yahoo requires an app specific password if it doesn't have the built-in security certificates or whatever.  Sounds like gmail is the same way.  If you can do that, it should work (assuming it's the same idea as yahoo mail).
Title: Re: mail notification not received
Post by: petediscrete on January 11, 2017, 02:49:25 AM
I did indeed Nolio. One of the first things I tried and no luck either.

I have a number of other web based apps sending email notifications with no problems. SSMTP is set up fine and sending mails from the terminal to my Gmail email address too.

The problem I'm starting to experience is that previous solutions with links are no longer working for my current setup. Wheezy is on it's way out and of course Mono 4x is a complete no no for HG.

What completely throws me is the fact that I made no changes to HG nor did I update the RPI. With email notifications not working for me it has all but killed off HG for me. Such a shame as I spent so much time configuring it over the last couple of years.

Title: Re: mail notification not received
Post by: bkenobi on January 11, 2017, 05:33:39 PM
It's been a while, but as I recall, installing monodevelop caused problems due to the version I selected.  I don't recall what the resolution was at this point, but that's why I made that guide (I needed it for myself as much as I wanted to help the community).  It's possible things have changed and the guide doesn't work with current versions though.
Title: Re: mail notification not received
Post by: petediscrete on January 11, 2017, 08:04:15 PM
That's exactly my problem Bkenobi. Version numbers are now becoming a big issue.

If Gene is busy working on documentation he might be advised that some of his documentation may well be out of date by the time he completes it. What we really need to get to is a working version of HG running under Raspbian Jessie and the latest stable of Mono as far as the Raspberry Pi is concerned.

The single board computer headless server is the way forward as far as I can see. Not much point running energy consumption measuring apps on a full blown desktop computer.

Title: Re: mail notification not received
Post by: raptorjr on January 11, 2017, 11:12:37 PM
I know very little of Mono, but it feels that if something works on Windows it should work on Linux with Mono also. Otherwise it is Microsoft that has a problem.

But I do agree that it would be nice if Gene could invest some time in the project again. I'm very impressed with what he have done with HG, and have no doubt that if he is working on the documentation that it will be equally good. But what does that matter if there is no one left using HG when he is done?

It would be nice if he could find the time and be a little more active on the forum. And why not publish the documentation even if it is not finished? I would really like to learn more about HG and be able to help with new features and fixing bugs. But I have a really hard time to learn this. Part of the problem is that I have never developed for the web. More documentation would be great.
Title: Re: mail notification not received
Post by: bkenobi on January 11, 2017, 11:51:22 PM
FWIW, Gene has published 2 versions of documentation already.  The first version was really rough but the second was much better.  The documentation is better today than it was for rev 2 so if you need help with something, what he's written should be there.

If you haven't checked out the current documentation, it's pretty good for the most part.  Go to the main page and select "developer docs"

http://genielabs.github.io/HomeGenie/about.html (http://genielabs.github.io/HomeGenie/about.html)

Documentation for writing code is located in the "Helper Class Reference" and API/web is located in the "API" section (right side of screen).  You can either drill down to the help topic needed or search for something.  Many items include examples but all include the required syntax.