Vera UI4 How to get Email notification working using the Lua smpt socket

Recently I bought a Vera 2 system with a few power switches ( Everspring AN157 and AN158) for evaluation first and to be used later in my second home for control purposes.
I upgraded the unit to the latest beta release firmware 1.1.1234

I had in mind to build some extra functionality to control the status of my switches after a power line failure on a single phase.
For instance If the switch becomes unpowered its state will be OFF after power comes up again while Vera’s event timer still could be programmed to be in the ON state. So I would like to send a Email notification by checking the device Commfailure flag and then using the Lua smpt socket for the notification.

There are a few more events I would like to check this way other then the device status change notification used in the Scene tab “Notification”. Since the Vera UI4 does not have other options yet for notification I was looking for a different way of notification and without using de MIOS server facility.

I tried the event notification described in the topic Device loses communication with MiCasaVerde found here: http://forum.micasaverde.com/index.php?topic=5330.0
I used exactly the same code but for some reason I cannot get it to work in the scene tab Luup . Of course I did change the user variables to match the email account.

Running the code in Micasaverde developers test LUUP code (lua) does not give me a clue.
It runs successfully without code error. But only if I ad the code “return true” on the end otherwise I get “Code error”.
This seems to be necessary for some reason, all other code I tested in test LUUP code works fine this way.
(Can somebody explain why I need to put “return true”?).

There is another topic which describes a useful way how to do email notification based on the same smtp socket in this topic:
Alerter for Drowsy Devices (ADD)
See: http://forum.micasaverde.com/index.php?topic=5130.0

In both topics it looks that these examples should work fine within the Vera V2 UI4 systems .

In another topic: UI4: creating users without a myMIOS account
See http://forum.micasaverde.com/index.php?topic=4323.0
Here however it seems impossible in the Vera UI4 to use the smpt socket option.

Am I right or do I mix up things now ?

Who can help me out ?.

Are you sure you have your SMTP server settings correct, and that they don’t require an SSL or TSL connection?

Thanks for the fast reply strangely.
I checked this but my smtp server does not require SSL or TSL. I used the same settings as in my outlook account.
I also did portforwarding port 25 in my modem just in case it was neccesary.
Will Vera report the errors in the log if smtp server settings would be wrong ?

I have added the most recent code here to check for any error.

Try adding

luup.log('r='..tostring(r)..'*e='..tostring(e))

to the code (just after the call to [tt]smtp.send[/tt]).

Finally I got it to work !
Since my email account does not require Authentification from my home IP I removed
user = SMTP_AUTH_USER,
password = SMTP_AUTH_PW
from the send.smtp string and the variable USER_SENDING must contain my emailadress.
I did a telnet sesion first to the smtp server of my ISP to find this out.
This is the code that works for me now:

[code]–
– BEGIN user adjustable variables

local SMTP_SERVER = “smtp.tiscali.nl”
local SMTP_PORT = “25”
local USER_SENDING = “my_email_adress”
local USER_RECEIVING = “my_email_adress”

local smtp = require(“socket.smtp”)

local from = USER_SENDING
local rcpt = {USER_RECEIVING}

local subject_out = “test2”

local message_out = “hello”

local mesgt = {
headers = {
to = USER_RECEIVING,
from = from,
subject = subject_out
},
body = message_out
}

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

I tried the same with my Gmail address by adding the code
user = SMTP_AUTH_USER and password = SMTP_AUTH_PW again and using my Gmail account details since Gmail requires a username and password.
Unfortunately this seems not to work because Gmail uses TSL and I read similar results in other micasaverde topics.
Anybody a solution for this ?

Has anyone been able to get SMTP emails working where the server requires user name and password to authenticate rather than IP address?
I am trying this with U5. The server I am using, unlike GMail, does not use SSL/STARTTLS, but it does authenticate with user name and password and not by IP address.
Like everyone else, I require(“socket.smtp”) but I get no emails when I run my tests.

Also, has anyone tried the alternate Lua SMTP from nmap.org, instead of the very questionable implementation available through socket.smtp?