SMS without findVera.com

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.

The newer firmware versions started to include more of the LuaSocket library, including the [tt]smtp[/tt] 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.

        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. [tt]1115551212@txt.att.net[/tt]

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!

http://wiki.micasaverde.com/index.php/Luup_Lua_extensions

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

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 :slight_smile:

I’ll wait till someone writes an example of gmail notifications :slight_smile:

@325xi, looking at LuaSec ([tt]ssl.lua[/tt]), the example I provided is about 10 minutes away from having TLS support. LuaSec is included in Vera, so if you want to experiment… :slight_smile:

Basically you’d break out the call to [tt]smtp.open[/tt], 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…

I spend this weekend working on EtherRain improvements suggested by skiblawi, and also on implementing pan-tilt for icamview - enough for today :slight_smile:
But if you have email working, why wouldn’t you just post it?

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 :slight_smile:

That should work great. My SMTP is local to Vera and doesn’t use SSL.

Thanks!

@SRACP, let me know how it goes.

btw, thanks for changing the title/subject line :slight_smile: 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)

[quote=“guessed, post:12, topic:165914”]@SRACP, let me know how it goes.

btw, thanks for changing the title/subject line :slight_smile: 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)[/quote]

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

[quote=“guessed, post:12, topic:165914”]@SRACP, let me know how it goes.

btw, thanks for changing the title/subject line :slight_smile: 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)[/quote]

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.

@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…

I have the following code sending txt fine to one cell, I can’t seem to get it to send to more than one rcpt, I’ve tried:

rcpt = { “”, “” }

I’d also like to find a way to add the user id and vera’s date and time stamp.

[code] local smtp = require(“socket.smtp”)

    local SMTP_SERVER = "192.168.1.3"
    local SMTP_PORT = "25"
    local USER_SENDING = "<Vera@XXX>"
    local USER_RECEIVING = "<5551212@Txt.ATT.net>"

    local from = USER_SENDING
    local rcpt = {USER_RECEIVING}

    local mesgt = {
        headers = {
            to = USER_RECEIVING,
            subject = "Someone Has Entered The Back door."
        },
        body = "The back door has been used."
    }

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

    if (e) then
        luup.log("Yikes " ..  e)
    end[/code]

the date bit is easy, just use [tt]os.date(“%c”)[/tt] as in:

body = "The back door has been used. " .. os.date("%c")

and it’ll print something like the following in the Message body:

The back door has been used. Mon May 17 16:29:53 2010

or a similar combination of formatting masks from:

http://www.lua.org/pil/22.1.html

The multi-email thing is just going to take some googling and experimentation. What you’ve written technically looks correct.

Just wanted to let you know that worked great!

The only issue I have now is multilple email addresses and the code for who unlocked the door. I’ve asked support for that info. Otherwise it works great for lock notifications not tied to a pin code.

Any word on using gmail for notifications or ssl based smtp? I would like to use my own email instead of Vera for notifications. I looked on the forums and have not really found a true solution or posts of been vague on integrating your own email.

  • Garrett

Gmail is tricky until someone bites the bullet and develops a plugin, but I use Twitter for notifications for few months and it proved to work much better then I ever expected.