[ul][li][tt]luup.call_action( “urn:upnp-ap15e-com:serviceId:SND1”, “SendMail”, { subject = ‘Message from Vera’, body = ‘How are you today?’ }, 11 )[/tt]
replace [tt]11[/tt] with the SND device ID.[/li][/ul]
History:
V0.2 fix for DeviceType (thanks to oTi@), UPnP parameters: subject, body
V0.3 update for UI5
V0.3a removed [tt]isSingle[/tt] from static json file for compatibility with UI4
Remarks:
[ul][li]RFC 2821 requires all lines of the message body to end with CRLF.[/li][/ul]
— edit—
first remark, downloading now works without having to sign in! Thats 1 improvement!!!
—edit 2–
Where would the luup line mentioned under usage go? In the luup code tab/field of a created event?
That is how i created it and it doenst send messages on the trigger set
–edit 3–
In the original code i had to comment out the AUTH lines since my SMTP server doesnt require them.
Now i have two emtpy fields in SND and am of course unable to comment then out of the code.
I remember that email didnt work with the lines of code active without input…
Can this be the reason why no messages sent so far?
@Henk, did you change the device number of the code to match the SND device that was created?
(luup.call_action( “urn:upnp-ap15e-com:serviceId:SND1”, “SendMail”, { message = ‘Message from Vera’ }, 11 )
*(replace 11 with the SND device ID.)
@Ap15e, works great.
“Message from Vera” appears in the emails subject (which is easily changed for the event)
Each of the 12 test emails generated had a single random letter or number in the body of the email when they were received.
w,u,5,a,d,c,u,m,o,f,0,5
[quote=“JOD, post:3, topic:168408”]@Henk, did you change the device number of the code to match the SND device that was created?
(luup.call_action( “urn:upnp-ap15e-com:serviceId:SND1”, “SendMail”, { message = ‘Message from Vera’ }, 11 )
*(replace 11 with the SND device ID.)
JOD.[/quote]
@JOD yes i did, i used the device ID of the light that i was switching (15) and yes i know that was not the idea
and yes i used the ID of SND (24). No messages on both settingchanges
Got it to work!
Seemingly there are some spaces in the code when cutting and pasting it.
After removing the space after the SND device Id my messages started coming.
–edit–
Messages sent YES, messages received 0
Do i need to set the variables within quotes? (like “send.this@email.eu”) and SMTPport “25”???
Strange thing is, ADD sends hearbeats perfectly with exactly the same settings as i used in SND
Q. Can the number of sent messages be purged?
A. Yes, by manually changing it back to 0 in the advanced tab
Q. Can ADD use this device too so that only one UpNP-SMTP bridge/code is needed in the system?
I must look silly… but i cant receive the email (ADD works…). I can only deduce that it isnt being sent by SND.
I SEE the SND device working (message counter stacks) so i know the luupcode in the event is working (with correct SND device ID)
I’ve tried everything from retyping all variables, stated the IP instead of name of my SMTP host
Set username/password to 0, tried “” in those fields… nothing!
I know for a fact this was the same issue i had with my ADD device, not mailing heartbeats.
I solved this by completly commenting out the AUTH_USER & SMTP_AUTH lines like shown below.
local SMTP_SERVER = "my.smtp.host"
-- local SMTP_AUTH_USER = ""
-- local SMTP_AUTH_PW = ""
local SMTP_PORT = "25"
local USER_SENDING = "sender@my.vera"
local USER_RECEIVING = "receiver@gmail.com"
Only after actually commenting out the code, did my ADD device start to send heartbeats.
The only thing i can imagine now is that these fields are in the SND code and my SMTP host doesnt accept the empty request. Can i try and remove them from the apropriate xml to troubleshoot?
I know ill loose the variables then, but thats less bothersome than not receiving the notifications.
Whats left now is how to edit the json file… can i safely comment out stuff there?
@Ap15e
Is there another way to code this? or does it have to be hardcoded and users have to exclude the lines manually edit their xml files if they have the same issue i was having? Maybe you could code the variables in such a way that they only create output if there is actually data in the fields and not send the requests to the server emtpy?
Functionalitywise, is it possible to add variables to the textbody like timestamp, day of week etc?
If so, are there standard luup variables to use then? I took a look at the wiki and found something like “os time()”
/but how would i incorporate that into the body of the message?
Excellent. For clarification, I use authentication on both my own server as well as my ISP’s, so my situation is different. I do think this can be coded differently, although one could perhaps argue that the root problem is the robustness of the SMTP library.
Yes, and i solved it. In ADD comment out 2 lines using " --"
Here is the example:
local SMTP_SERVER = "my.smtp.host"
-- local SMTP_AUTH_USER = ""
-- local SMTP_AUTH_PW = ""
local SMTP_PORT = "25"
local USER_SENDING = "sender@my.vera"
local USER_RECEIVING = "receiver@gmail.com"
Yes, and i solved it. In ADD comment out 2 lines using " --"
Here is the example:
local SMTP_SERVER = "my.smtp.host"
-- local SMTP_AUTH_USER = ""
-- local SMTP_AUTH_PW = ""
local SMTP_PORT = "25"
local USER_SENDING = "sender@my.vera"
local USER_RECEIVING = "receiver@gmail.com"
[/quote]
I’m surprised it worked for you - I needed to patch the code (attached under provided link) for that to work…
@denix,
For SND @Henk did comment out the parts in the smtp.send() call (as well). And although not stated as such here, the same may be true for ADD, per @huogas’ and @Henk’s comments over there based on your findings.