more G-Labs products

Author Topic: Email still does not work  (Read 2597 times)

November 23, 2015, 02:52:35 PM
Read 2597 times

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Now that HG 1.1 r501 is working correctly for X10 again, I want to figure out how to get Email notifications back up and running.  I know that using the last HG RPi image I downloaded I could email out of the box.  Somewhere around r480 they stopped working.  I assume this was due to what mono runtimes HG was utilizing and not mono itself since I could actually switch between versions to make email work or fail.

I have tried to follow the various threads on the HG forum to get email back, but I keep having the same 2 issues.  I first apply fixes one at a time where they don't work and eventually HG won't load.  I am currently starting from a clean slate and would like a simple set of instructions for what commands actually work.  My current configuration is:

RPiv1B
Debian wheezy 5/5/2015
HG 1.1 r501

I have a set of instructions I have been constructing to provide a step-by-step guide to creating a RPi HG image and email support is something I want to include.

November 23, 2015, 04:25:42 PM
Reply #1

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I'm running HG on a Windows machine and have just tested sending an email and it works OK. I'll plug in my BananaPi this evening to see if it works there.

Could you give us more info on the mail server you are using?


November 23, 2015, 05:08:41 PM
Reply #2

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I was using yahoo mail before but I've also tried using gmail.  When I had it set up before, I believe I had to use an app specific password and was using port 465.  I've attached my guide for constructing a working system (to my specs).  I haven't finished it yet, but it's pretty close as far as steps that I've fleshed out.

November 23, 2015, 06:09:27 PM
Reply #3

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
I also use yahoo mail with HG on Win7 for some time now.  Here are the program settings I have...

Email address: <username>@yahoo.com
SMTP server: smtp.mail.yahoo.com
SMTP username: <username>    //before @yahoo.com
SMTP password: <password>
SMTP Mail Server port: 587
SMTP Mail Server use SSL (TRUE or FALSE): TRUE



November 23, 2015, 06:28:31 PM
Reply #4

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I haven't used Windows for testing HG in a while, but the issue seems to be that RPi doesn't fully support the most up to date version of mono.  As a result, the standard repository will only install mono 3.2.8.  However, in order to get SSL certificates working mono needs to be at 3.12.0 (if memory serves).  I have been able to update mono to newer versions up all the way up to 4.0.4, but when I do that, HG starts to have issues.  I'm not sure this is related to mono, but it seems possible.

Yesterday I updated a few things on a working system and broke HG such that it won't load.  It doesn't output anything from the standard output but I just realized I was dumping error output to /dev/null.  I will see if there's any error messages that will help diagnose the issue.  Perhaps that will also help explain why some people seem to be able to use email on RPi.

November 23, 2015, 06:49:35 PM
Reply #5

jshan

  • ***
  • Information
  • Full Member
  • Posts: 71
I am successfully using Yahoo mail with HG and mono 3.2.8 on rPi with r493 and r501.  Here's how I did it: http://www.homegenie.it/forum/index.php?topic=1004.msg6206#msg6206

Good luck.

November 23, 2015, 07:30:56 PM
Reply #6

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
That's one of the threads I was using as a guide.  I hoped it would work as easily as you found, but I ran into issues.  The last time I tried to install mono-complete it seemed to cause HG to stop working.  It's possible that the culprit was something else I updated at the same time, though.  I believe running the distro update broke my current setup so perhaps that's what I did before.
Code: [Select]
sudo apt-get dist-upgrade
When I installed mono-complete I believe the issue was also that HG wouldn't start.

EDIT:  I just noticed you updated the other thread.  I didn't realize you were using port 587.  I tried that before and it didn't work.  I'll try that port when I get my system back up.
« Last Edit: November 23, 2015, 07:32:49 PM by bkenobi »

November 24, 2015, 07:27:55 AM
Reply #7

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
With my backup SD card installed, I tried installing mono complete again.  This time I did not see errors during install.  I think part of the reason is that I did not try to update to the current version of mono first.  As a result I have mono complete 3.2.8 installed and seemingly working.  I then followed the remainder of the directions posted in the above link.  But, with my simple test APP I still get errors and no email.

Code: [Select]
2015-11-23 22:04:38.6507 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
2015-11-23 22:04:38.6553 Info HomeAutomation.HomeGenie.Automation 1006 Automation Program Program.Notification {"Title":"Ip Information","Message":"Mail send"}

And the code I'm using to run this is:
Code: [Select]
var subject = "test email";
var messagetext = "HG Test Email";
var recipients = "[email protected]";
Net.SendMessage( recipients, subject, messagetext );

I used the settings as suggested:
E-Mail address:           [email protected]
SMTP Mail Server address: smtp.mail.yahoo.com
SMTP username (optional): myname
SMTP password (optional): mypassword
SMTP Mail Server port:    587 (and 465 as another test)
SMTP Mail Server use SSL: TRUE

Any other suggestions?

November 24, 2015, 08:00:52 AM
Reply #8

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I have little to no knowledge of Yahoo mail, but with Gmail I have two factor authentication setup which makes it difficult to send emails from an 'unknown' machine. Could that be the case for you?

Do you have access to another SMTP server? If not I can give you temporary access to mine to see if it works via that route. If that works we will at least know if System.Net.Mail is working on your Pi (or not)

November 24, 2015, 08:23:38 AM
Reply #9

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I tried gmail when I had yahoo working before but couldn't figure it out.  I could switch to gmail if that worked since i have both types of email.

November 24, 2015, 08:54:21 AM
Reply #10

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Sorry, I was unclear. I'm running a personal SMTP server, if you want to have access for testing let me know.

November 24, 2015, 04:47:05 PM
Reply #11

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I spent a bunch of time last night trying to configure mono correctly based on what I thought was needed.  I have mono-complete installed, but it didn't seem to make any difference. 

This morning I tried one last thing to verify that the account itself was working.  Since I'm using yahoo mail, I need an app specific password.  I had one that I tested weeks ago and was working using openssl but I decided to request a new one to start fresh.  With this new password, I followed some examples of manually sending messages.  The basic flow is:
Code: [Select]
openssl s_client -crlf -connect smtp.mail.yahoo.com:465
ehlo localhost
auth login
<base64 encoded email address>
<base64 encoded app specific password>
mail from: <[email protected]>
rcpt to: <[email protected]>
data
this is a test email
.
quit

This worked every time.  I sent several messages and it always worked.  I then tried using the same settings in HG and it failed several times.  There was a red herring in the log indicating an error with the script since there was no reason for the error listed in mono output.  I then tried switching to 587 as a last ditch effort and it worked.  I don't know why, but 465 used to work and 587 did not but now it's the other way around.

I will finish my RPi SD card setup guide over the next few days but it appears that some combination of mono-complete, switching ports, and requesting another app specific password has currently gotten my setup working again.

November 24, 2015, 05:25:11 PM
Reply #12

jshan

  • ***
  • Information
  • Full Member
  • Posts: 71
Glad to hear you were successful, bkenobi. 

February 09, 2016, 02:40:10 AM
Reply #13

mchias13

  • **
  • Information
  • Jr. Member
  • Posts: 45
Email was driving me crazy.  I couldn't get it to work with Gmail or Yahoo following any of the instructions on here.

I set up a local email server on my pi following these instructions:  https://samhobbs.co.uk/2013/12/raspberry-pi-email-server-part-1-postfix

I had to tell Gmail that the emails are not spam, but no issues sending as text message to my phone.  I have a freedns set up for my home, so that was the domain that I used.