Sending EMAIL (simple)

A simple example to show how to send out an email on a state change.

Whenever relay 1 changes state an email is sent - very contrived to keep it simple.

Brett

Member for

14 years 6 months

magill

12 years 6 months ago

Hi

I've been trying to get this script to work using my Gmail credentials. Tried port 465 and 587. I've had no success. Anyone else?

thanks

John

Member for

14 years 6 months

magill

12 years 6 months ago

Anyone? I don't know whether to persevere or give up. Gmail seems to require "SSL"

thanks

John

Member for

16 years 10 months

brett

12 years 6 months ago

I can take a look when I get some time. I have a gmail account I can test with.

A quick google and I find this: http://stackoverflow.com/questions/11070623/lua-send-mail-with-gmail-ac… which requires lusec https://github.com/brunoos/luasec/wiki that is a wrapper around openssl.

openssl is not installed on the livebox but it is compiled and linked with when libcurl is setup, and its libcurl that we have, this is use for twitter and googlecal (albiet broken).
I've not looked into it but we could make libcurl dynamically link with openssl and then it include it, which would allow things like luasec to also use this openssl .so library file too which would provide SSL support to LUA enabling gmail...

OR

Given libcurl is already on the box just include a small xap-gmail program that does the handshaking for you and provides a nice xAP interface to chat with.  I'm thinking this route is simplier even if its very gmail specific.

http://talkbinary.com/programming/c/how-to-send-email-through-gmail-usi…
http://manojadinesh.blogspot.com.au/2012/11/smtp-libcurl.html

Brett

Member for

14 years 6 months

magill

12 years 6 months ago

Brett

You're a superstar. I fiddle around a bit with VB net and some PHP and I'm in awe of how quickly you can provide a solution to our problems. When I suggested the sunrise/sunset scenario you had a solution in about an hour!! I hope others find this useful. One use I have for email is to send SMS via an email to sms service. Maybe Twitter provides a better solution, I have never used it.

All works well, but a couple of things

The GUI makes an entry in the ini file "passwd", should that be "password"

also

I get a response:-

Error Message: A xAP message received was malformed. Object reference not set to an instance of an object.
Received From: 10.0.0.40:59203

xap-header
{
target=dbzoo.livebox.Mail
class=email
}
message
{
to=*******@gmail.com
subject=How is your lamb?
text=I'll be around for dinner tonight at 6pm
}

Not sure what that means..

thanks again

John

Member for

16 years 10 months

brett

12 years 6 months ago

John,

I fixed the password problem, thanks for noticing that, I was in a hurry when I wrote this.  Try 314.2

I've also updated the wiki page xAP packet sample which wasn't suppose to be taken literally as a cut/paste. It would not have worked. As you found out.  It was missing several required fields which is why you got errors.   Anyway I updated the wiki page with a full payload sample.   I also noticed an error in the ok/error class it was class=mail and it should have been class=email for consistency but this was not a show stopper.

Brett

Member for

14 years 8 months

Lawrencezarb

8 years 7 months ago

Is it possible to adapt the script use an email account that requires SSL authentication?