We have moved at community.getvera.com

Author Topic: SMS without findVera.com  (Read 14717 times)

Offline SRACP

  • Sr. Newbie
  • *
  • Posts: 39
  • Karma: +0/-0
SMS without findVera.com
« on: May 09, 2010, 11:48:51 am »
Is it possible to use my own mail server to send SMS text using my own SMTP mail server? One of the main reasons I went with Vera was to eliminate the need for a third party.
« Last Edit: May 09, 2010, 04:29:57 pm by SRACP »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: SMS without finder.com
« Reply #1 on: May 09, 2010, 01:31:05 pm »
The newer firmware versions started to include more of the LuaSocket library, including the smtp package, so it's technically possible to do what you want with some Lua code.  I'm not sure what version intro'd the package, since the release notes aren't detailed.

It will require some experimentation though, along with an SMTP Server that doesn't require SSL (as far as I can tell, I could be wrong here).

The Lua code would look something like the following snippet.  I've not been able to test this since my SMTP Server is SSL-only, which I haven't gotten to work.

Code: [Select]
       local smtp = require("socket.smtp")

        local SMTP_SERVER = "plus.smtp.mail.yahoo.com"
        local SMTP_AUTH_USER = "guessed"
        local SMTP_AUTH_PW = "xxxxxxxxx"        
        local SMTP_PORT = "25"
        local USER_SENDING = "guessed@example.com"
        local USER_RECEIVING = "guessed@example.com"

        local from = USER_SENDING
        local rcpt = {USER_RECEIVING}

        local mesgt = {
            headers = {
                to = USER_RECEIVING,
                subject = "My first message from Vera"
            },
            body = "This is a test of sending mail from Vera, directly."
        }

        local r, e = smtp.send{
            from = from,
            rcpt = rcpt,
            source = smtp.message(mesgt),
            server = SMTP_SERVER,
            port = SMTP_PORT,
            user = SMTP_AUTH_USER,
            password = SMTP_AUTH_PW
        }

        if (e) then
            luup.log("Yikes " ..  e)
        end


From there, SMS would just require the Email-address style that your SMS provider uses.

eg. 1115551212@txt.att.net

Offline Les F

  • Hero Member
  • *****
  • Posts: 567
  • Karma: +7/-0
Re: SMS without finder.com
« Reply #2 on: May 09, 2010, 01:48:44 pm »

okay, where can I find out all the goodies that can be done on vera with lua?   I browsed the lua programming guide
but found it lacked any details on the 'hooks' into vera.  Good stuff like the script you included for SMTP.

Thats the kind of stuff I want to see.   I sort of relate this to reading the old "Programming in C" book.  Great I can program in C, but what it never told you was all the cool linux/unix system calls that were out there as well.  (Okay, I am starting to show my age).   Without knowledge of both, you couldn't do much useful stuff.

If there are better examples related to Vera and the newer firmware, please point me in the right direction. I know there are a couple of examples in the wiki, was just looking for more.

Thanks!
Google+ http://bit.ly/2MAVlkR / Instagram: http://bit.ly/2lIcsFT / Pinterest http://bit.ly/2KCSYRm (Yes, Pinterest is for guys too! take a look)

Offline mikeholczer

  • Sr. Member
  • ****
  • Posts: 413
  • Karma: +0/-0

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: SMS without finder.com
« Reply #4 on: May 09, 2010, 02:19:07 pm »
What's interesting is how to enable TLS, so we could use gmail smtp


Said that, you could use Twitter that can do both SMS and email for you.
http://forum.micasaverde.com/index.php?topic=2320.msg13431#msg13431
« Last Edit: May 09, 2010, 02:31:45 pm by 325xi »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: SMS without finder.com
« Reply #5 on: May 09, 2010, 02:30:54 pm »
Javier has indicated that he'd be formally documenting (wiki) the Lua libraries/packages that are pre installed in Vera, but you can mostly work them out by looking in the directories on Vera itself since Lua uses a standard Path to locate them (similar in nature to LD_LIBRARY_PATH for C programmers)

LuaSocket is the one that the SMTP lib comes from, so standard doco can be found online for that one.

325xi: yes, I haven't delved into the package enough to see if TLS is supported or not just yet, but it certainly does auth :)

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: SMS without finder.com
« Reply #6 on: May 09, 2010, 02:32:53 pm »
I'll wait till someone writes an example of gmail notifications :)

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: SMS without finder.com
« Reply #7 on: May 09, 2010, 03:12:19 pm »
@325xi, looking at LuaSec (ssl.lua), the example I provided is about 10 minutes away from having TLS support.  LuaSec is included in Vera, so if you want to experiment... :)

Basically you'd break out the call to smtp.open, to get the socket handle, then wrap that with relevant calls to add TLS/SSL from the example at:

    http://www.inf.puc-rio.br/~brunoos/luasec/

... before using it to send the message.  Right now, I've got it setup as connect-and-send, all in one call.  At least it roughly looks that way...

Offline 325xi

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1101
  • Karma: +0/-0
  • V1, V2, still V2...
Re: SMS without finder.com
« Reply #8 on: May 09, 2010, 03:28:40 pm »
I spend this weekend working on EtherRain improvements suggested by skiblawi, and also on implementing pan-tilt for icamview - enough for today :)
But if you have email working, why wouldn't you just post it?

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: SMS without finder.com
« Reply #9 on: May 09, 2010, 03:50:21 pm »
Ah, I'm working on SQRemote and IR stuff this weekend, and I figured I'd let someone else take the reins. 

The hints I provided were done to see if I could spur someone into doing it (teach people to fish and all), not necessarily you  :)

Offline SRACP

  • Sr. Newbie
  • *
  • Posts: 39
  • Karma: +0/-0
Re: SMS without finder.com
« Reply #10 on: May 09, 2010, 04:24:16 pm »
That should work great. My SMTP is local to Vera and doesn't use SSL.

Thanks!

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: SMS without findVera.com
« Reply #11 on: May 09, 2010, 04:33:55 pm »
@SRACP, let me know how it goes.

btw, thanks for changing the title/subject line :-)    You might want to move this to the Luup area if it becomes more "code" like in it's discussion.  Maybe once it's working we can encourage MCV and Team to add it more natively (with Vera SMTP Server Preferences and stuff)

Offline SRACP

  • Sr. Newbie
  • *
  • Posts: 39
  • Karma: +0/-0
Re: SMS without findVera.com
« Reply #12 on: May 09, 2010, 04:36:00 pm »
@SRACP, let me know how it goes.

btw, thanks for changing the title/subject line :-)    You might want to move this to the Luup area if it becomes more "code" like in it's discussion.  Maybe once it's working we can encourage MCV and Team to add it more natively (with Vera SMTP Server Preferences and stuff)

My stupid iPad corrected the findvera.com to finder. LOL

Offline SRACP

  • Sr. Newbie
  • *
  • Posts: 39
  • Karma: +0/-0
Re: SMS without findVera.com
« Reply #13 on: May 11, 2010, 01:16:57 pm »
@SRACP, let me know how it goes.

btw, thanks for changing the title/subject line :-)    You might want to move this to the Luup area if it becomes more "code" like in it's discussion.  Maybe once it's working we can encourage MCV and Team to add it more natively (with Vera SMTP Server Preferences and stuff)

It's working fine with my Exchange Server. Just need to tweek a few things. Mine is set not to relay so I removed the auth and just allowed Vera's IP to get around the relay restrictions. I need to tweak it to include which user and other variable data in the body.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: SMS without findVera.com
« Reply #14 on: May 11, 2010, 09:42:02 pm »
@SRACP,
Good to hear!

The internals of socket.smtp wont send the Username/Password combo if they're either not present, or Blank (from memory).... so you're safe to remove those if AUTH isn't required.

I only had them in the sample as the Yahoo SMTP servers I was playing with required them...