HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Raspberry Pi GPIO/SPI/I2C => Topic started by: pinie_pinie on February 19, 2017, 08:00:00 PM

Title: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 19, 2017, 08:00:00 PM
Hello,
Use HG 5.25 on a raspberry.
A great program. Unfortunately, I do not send emails.
Does anyone have experience on this subject? I use my "web.de" account.
On my main computer runs "Outlook" (Office) perfectly.
Also a small test program (Send_Test_e-mail.hgx) does not send mail.
Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on February 19, 2017, 08:32:07 PM
Hi, pinie_pinie.
Have you installed ca-certificates-mono package?
Also, try to use 25 port for SMTP server settings.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 20, 2017, 04:45:28 PM
Hello,
no I did not.
The link in the guide does not work.
"sudo apt-get install ca-certificates-mono"

Do you have a tip where I can load the package?

Many Thanks!!!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on February 20, 2017, 04:49:16 PM
Take a look at official Mono documentation: http://www.mono-project.com/docs/getting-started/install/linux/ (http://www.mono-project.com/docs/getting-started/install/linux/)
You need to execute these 3 steps before installing ca-certificates-mono:
Code: [Select]
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 20, 2017, 06:49:34 PM
Hello,
Has done everything.
The package I could now also install (ca-certificates-mono)

But now HG does not start anymore. The Raspberry is accessible via SSH and remote.
Have HG re-installed.
Unfortunately without success.

Many Thanks!!!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on February 20, 2017, 08:02:24 PM
Hm, it's strange.
Could you try to run HG directly from the console? Go to HG installation folder and run
Quote
mono HomeGenie.exe
Attach here console output. It should contain useful information.

Edit: also you can try to connect to your HG on port 8080.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 20, 2017, 08:17:28 PM
Hello,
Now runs HG.
I have sudo apt-get update + sudo apt-get upgrade done.
After a reboot I reached HG.

Unfortunately, email still does not work (port 25 or port 587).
Do you have a good idea?

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on February 20, 2017, 08:32:42 PM
Glad to hear that your HG is now working.
To investigate email problems I can only advise you to try to use my binaries with extended tracing around sending emails.
- stop HG
- backup your HomeGenie.exe and Linux.dll files
- replace them with attached files
- edit your NLog.config file like this:
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <targets>
     <target name="debugger" xsi:type="Console" layout="${longdate} ${level} ${message}"/>
     <target name="logfile" xsi:type="File" fileName="${basedir}/log/${level}.log" />
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="debugger" />
    <logger name="*" minlevel="Trace" writeTo="logfile" />
  </rules>
</nlog>
- start HG

After that in your log folder you will see Trace.log file where you will find some strings with HomeGenie.Automation.Scripting.NetHelper. They contain info about the process of sending emails. Be careful before posting these logs here as they will contain your password in plain text.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 20, 2017, 08:36:31 PM
Hello,

I will definitely try it. Must now go to work. Report me tomorrow and share the result.
Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 21, 2017, 11:55:36 AM
Hello,
The files exchanged. Unfortunately without success.
In the appendix you find the "Trace.log".
Note: I have set the "SSL" checkmark in the "email account". Is the error in the program?
No mails are sent. The small help program "Test e-mail" has not brought any error messages since the exchange of the files. The mail is still not sent.
Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on February 21, 2017, 12:57:11 PM
Well, there is a string "Error sending email {0}" and it's good, as you can search for actual error in Error.log.
When I have had problems with sending emails there was no error, Send function just stuck.

Also, I definitely have to remove "Domain": "bounz.net" I've used while investigating my own email problems. I'll post corrected binaries today evening.

About "SSL" checkmark in the "email account": I have set it up and it has been successfully saved. Have you pressed "Reload" (something like that) button in the popup with email settings?
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 21, 2017, 01:41:52 PM
Hello,
I'll send you my "error-log". There are a lot of errors about "Mail / SSL". Can not evaluate them unfortunately. Can you see where the error could be?
Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on February 21, 2017, 01:53:26 PM
Well, I think problem definitely is in sending email without SSL.
You should try to save the "Use SSL" checkbox in email settings of HG.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 21, 2017, 02:25:54 PM
Hello,
That was my first intention. I think the program does not save. Therefore my login is probably rejected (SSL required).
But what can I do with this problem? Can you give me the "E-Mail Account.hgx"
Send, or does that make no sense?
Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on February 21, 2017, 02:50:08 PM
Hello,
The problem sits in front of the calculator !!!!
My Raspberry had the wrong time zone (1h back). You have to come up with that.
Now runs the e-mail program without problems !!!!

Thank you very much for your support !!!!
I learned a lot.

Thoralf 
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on February 21, 2017, 06:06:07 PM
Glad to hear that everything work now!
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 06, 2017, 10:07:58 AM
Hello,

I need help.
My problem: A new installation on raspberry (HG 1.1.525 + mono). It works but the send of email do not work.
Email provider is @kabelmail.de. See the trace-log.
For the test i´m using the little program "Send e-mail".
Many thanks for your help!!!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: bkenobi on March 06, 2017, 05:14:16 PM
I'd verify your certificates are up to date (process described above).  IMO, the easiest way to determine if the issue is the RPi or HG is to manually send a message via sending the commands yourself from a terminal window.  If you can get it to work manually from the RPi where HG is installed, then the issue is HG.  If you can't get it to work manually, that's the first thing to figure out.  HG will never work if you can't send a message manually.
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 06, 2017, 08:43:17 PM
Thoralf,

Do you have any logs in Error.log at 2017-03-06 09:53:42.2835?
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 07, 2017, 03:19:27 PM
Hello,
Rasbian jessie + HG 5.25 + mono newly installed.
"Apt-get update + upgrade"
"E-mail account"
"Send a email.hgx"

No emails will be sent.
In the appendix the "Error.log" + "Trace.log"

On the surface of the Rasperry (Claws Mail) the email works.
In HG unfortunately not.

I'm desperate.

Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 07, 2017, 03:23:20 PM
And what about ca-certificates-mono package?
Take a look at official Mono documentation: [url]http://www.mono-project.com/docs/getting-started/install/linux/[/url] ([url]http://www.mono-project.com/docs/getting-started/install/linux/[/url])
You need to execute these 3 steps before installing ca-certificates-mono:
Code: [Select]
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb [url]http://download.mono-project.com/repo/debian[/url] wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
Title: Re: Sending email with HG 5.25 ???
Post by: bkenobi on March 07, 2017, 04:25:21 PM
As Bounz suggested, you need the ca-certificates-mono package to send email.  If you don't have that, you must use server without security certificates.  That basically means setting up your own server locally and having the certificates dealt with there.  I have a guide that I put together when I set up my RPi with Wheezy but it's outdated.  I have constructed a new guide for Jessie but forgot to upload it.  I'll add it to the following thread hopefully tonight.

http://www.homegenie.it/forum/index.php?topic=2152 (http://www.homegenie.it/forum/index.php?topic=2152)
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 07, 2017, 09:02:32 PM
Hello,
I have the certificate "ca-certificates-mono package" which describes Bounts already installed.
This does not work email shipping!
Do I need another certificate?

Many thanks for your help!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Jens on March 07, 2017, 09:31:01 PM
Did you try what helped me to solve the problem, certmgr and cert-sync?

http://www.homegenie.it/forum/index.php?topic=1957.msg11800#msg11800 (http://www.homegenie.it/forum/index.php?topic=1957.msg11800#msg11800)

Bests
Jens
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 07, 2017, 10:16:30 PM
Hello,

Has unfortunately not worked.
Mails are still not sent.
Too bad.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Jens on March 07, 2017, 10:37:03 PM
Can you perform a wireshark trace, that might give a clue

Bests
Jens
Title: Re: Sending email with HG 5.25 ???
Post by: bkenobi on March 07, 2017, 11:07:21 PM
In case you wanted to try the manual approach, here's a link:

http://www.yuki-onna.co.uk/email/smtp.html (http://www.yuki-onna.co.uk/email/smtp.html)

It's actually really easy and will quickly tell you whether the server is happy with your credentials or not.  I'm sure the other approaches work too, this is just what I did when I had issues.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 08, 2017, 05:13:29 PM
The data in the email account are correct. I have already checked this.
Nevertheless, the sending of emails works.
I absolutely lack a good idea.

Is it really so hard to send an email under HG?

Many Thanks!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: bkenobi on March 08, 2017, 08:32:44 PM
My configuration appears to be the same as yours.  I'm running an RPi with Jessie and HG 525.  I performed the exact steps documented in the text file and email works.  I did restore my previous setup, so it's possible that a setting in HG is different between default and my install.  But, I don't have any thing fancy.  I simply enabled the email app and entered server and account details.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 10, 2017, 06:23:56 PM
Hello,

HG after the instructions reconfigured. Unfortunately without success.
Who can tell me in which file the data from the "email account" are written?
I guess the problem.
Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 10, 2017, 08:55:01 PM
Settings are written into modules.xml file.
You can search the file for 'E-Mail Account' program. But the values of properties are encoded.
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 10, 2017, 09:36:29 PM
Also, please try to use attached binaries and NLog.config to log more information about the exception and after that attach Trace.log file.

Do not forget to backup yours before replacing files.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 11, 2017, 12:36:09 PM
Hello,

Where can I find the file "modules.xml"?
I have managed HG 5.25 with working email sending. I do not know why.
Then I tried to create a new SD card with HG5.25. I have everything
Made equal (HG5.25 + mono + Account) The email sending does not work !!!!
I can not understand why it is so difficult. I have the procedure determined already 20x repeatedly. Unfortunately without success. In my view, the email sending does not work stable, otherwise I could repeat the process without problems.

Thanks for your help!!!
Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 11, 2017, 02:55:44 PM
"modules.xml" file is in the root of your HG installation directory (at the same directory where HomeGenie.exe resides).

For simplifying testing email settings I wrote a little test program. Run it with
Code: [Select]
mono EmailTester.exeThe program uses the same method to send emails as HG does.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 11, 2017, 03:41:32 PM
Hello,

Now we are on the right track. I'm missing something. Your program runs on the old SD card (mail sending o.k)
On the new SD card is missing in the "mono" directory.
How do I get the missing post-installed?

Many Thanks!!!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 11, 2017, 04:50:06 PM
Well, it's very strange, but you can follow advice from this (http://stackoverflow.com/questions/10490155/unable-to-run-net-app-with-mono-mscorlib-dll-not-found-version-mismatch (http://stackoverflow.com/questions/10490155/unable-to-run-net-app-with-mono-mscorlib-dll-not-found-version-mismatch)) and this http://raspberrypi.stackexchange.com/questions/3363/the-assembly-mscorlib-dll-was-not-found-or-could-not-be-loaded-what-gives (http://raspberrypi.stackexchange.com/questions/3363/the-assembly-mscorlib-dll-was-not-found-or-could-not-be-loaded-what-gives) StackOverflow threads and try to install mono-complete package
Code: [Select]
sudo apt-get install mono-complete
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 12, 2017, 10:19:42 AM
Hello,

I can start the program. But get an error message.
On the old SD card the program works without problems.

So the error must be outside HG?

Many Thanks.

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 12, 2017, 10:31:54 AM
Well, Thoralf, something is wrong with your mono installation on the new SD card.
Are you sure you have installed ca-certificates-mono package?
Quote
The .NET Framework on Windows uses the Windows Certificates store (mmc, Add/Remove Snap-Ins, Certificates) to determine whether to accept an SSL certificate from a remote site. Windows ships with a bunch of Root and Intermediate Certificate Authorities (CA) and they get updated periodically by Windows Update. As a result, your .NET code will generally trust a certificate provided it was issued by a CA or a descendant of a CA in the certificate store (most reputable commercial CA's are included).

In Mono, there is no Windows Certificate store. Mono has it's own store. By default, it is empty (there are no default CA's that are trusted). You need to manage the entries yourself.

Take a look at http://www.mono-project.com/docs/faq/security/ (http://www.mono-project.com/docs/faq/security/) page, there are 4 methods described how to import SSL certificates into Mono certificate store.
But normally all these root certificated should be installed during Mono installation.

P.S. There is also an option to disable SSL certificate validation in code, but this is very bad practice.
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 12, 2017, 01:02:40 PM
Hello,

Of course. Have tried again to install. A reinstallation is made, which already has the latest version installed.
Can you uninstall "ca-certificates-Mono"?
Then I would reinstall "mono" completely.
I have already done several times, but something runs during the installation not clean.

Many Thanks!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 12, 2017, 10:02:12 PM
Hello,

I have reinstalled the SD card completely. Have only Rasbian jessie installed.
Then mono-complete and ca-certificates-mono package.
The program EmailTester works without problems. I was very confident.
Then I installed HG 5.25 and configured.
Unfortunately the email sending still does not work.
Is the sequence important when installing mono? Does anyone have an accurate
Instructions for the installation (Step by Step) of mono + ca-certicates-mono package?

Many Thanks

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: bkenobi on March 13, 2017, 04:17:33 PM
The guide I posted is exactly the commands I used to set up my RPi with Jessie last month.  I used Nov 2016 so newer Jessie could alter things possibly.  The only thing I can think of is that you are getting a different version of some package than the rest of us (different mirrors of the repository or something).  Perhaps you could check that the version numbers make sense?  I'm not sure what else to suggest since I provided my exact steps to get a working email setup.  Since we know it's outside of HG at this point, restoring HG settings should be a non-issue and that was the only difference I can think of right now.
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 13, 2017, 07:06:57 PM
Quote
Then I installed HG 5.25 and configured.
Unfortunately the email sending still does not work.

Email sending in HG or in EmailTester?
How do you install HG? Using .deb package or .zip archive?
Title: Re: Sending email with HG 5.25 ???
Post by: yoker77 on March 13, 2017, 10:02:27 PM
It works!!!

Hi,
i has been working together with Thoralf on this problem. Today we have been found the solution. The Solution could be found thanks to your help. Tomorrow we will send the the sequence of the installation, which leads reproducibly and safely to the target.

Many thanks at Bounz and bkenobi.

A question to Bounz: What is the function is of homegenie.exe. What is the difference between your homegenie.exe and the original?
Title: Re: Sending email with HG 5.25 ???
Post by: Bounz on March 14, 2017, 06:06:27 AM
The function of Homegenie.exe is to provide to user web interface and automation capabilities like Scheduler, Program runner, helper classes (like Module Helper, Network Helper) and so on.
You can see the differences between my version and Gene's version r525 on this pull request on GitHub: https://github.com/genielabs/HomeGenie/pull/308 (commit messages are more or less descriptive).
Title: Re: Sending email with HG 5.25 ???
Post by: pinie_pinie on March 14, 2017, 07:45:15 AM
Hello,

As already announced HG 5.25 the email shipping works!
In the annex a small guide for beginners. It has resulted from numerous experiments and combinations.
The key point is the exchange of "Homegenie.exe" (Bounz).
Thanks to all for their support!!!

Thoralf
Title: Re: Sending email with HG 5.25 ???
Post by: bkenobi on March 14, 2017, 03:35:52 PM
It looks like you are setting up your installation of JESSIE to use the WHEEZY repository.  Is that intentional?  I'm not sure what the technical differences are, but it seems that might lead to problems.
Code: [Select]
>echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
>sudo apt-get update

Also, I thought you were having a problem with certificates.  But, since you never install them it must have been something else going on.  This is how I install certificates for yahoo mail:
Code: [Select]
7) Set up SSL certificates
   sudo apt-get install mono-complete
   sudo apt-get dist-upgrade
   sudo certmgr -ssl smtps://smtp.mail.yahoo.com:465
   
   confirm setup:
   echo "" | openssl s_client -tls1 -showcerts -connect smtp.mail.yahoo.com:465

   *** yahoo and most likely google require an app specific password ***

With wheezy, there was a different package that also needed to be installed but this should work for Jessie.  If it worked, that echo command will show you a list of valid certificates from yahoo.  But, if your method works, great!   8)
Title: Re: Sending email with HG 5.25 ???
Post by: yoker77 on March 14, 2017, 09:16:53 PM
The method works without problems. It is perhaps still important to point out that the installation of sudo gdebi homegenie-beta_1.1.r525_all.deb takes very long. Before the actual installation of HG each lib lib-mono-files are loaded. I think, the SSL certificates will be there. It is important that the original homegenie.exe is exchanged for one of the variants of Bounz, otherwise the mail dispatch does not work.
Maybe you'll find time to implement the installation according to the scheme described.
With us at the moment the law of Murphy prevails: It works. But why?

Greets
yoker77