Page 1 of 1
sending email in dzvents script does not work
Posted: Tuesday 28 December 2021 17:46
by guenniac
Hi,
I'd like to send email notifications out of dzvents scripts, but that doesn't work.
I have setup an email server in Setup -> Settings -> Email. Testing from there works and both email addresses receive email.
But from dzvents nothing happens.
Example:
dz.email('SetHeatingLow', 'set all thermostats to 10°C', '
[email protected]')
Debug Log:
2021-12-28 17:26:59.350 Status: dzVents: Debug: - SendEmail = SetHeatingLow#set all thermostats to 10°C#
[email protected]
No more info found.
Advice is needed!
Thanks
Re: sending email in dzvents script does not work
Posted: Saturday 01 January 2022 17:41
by guenniac
Isn't there really nobody with an idea?
Any hints are really appreciated!
Re: sending email in dzvents script does not work
Posted: Saturday 01 January 2022 19:13
by madpatrick
You can check this thread
https://domoticz.com/forum/viewtopic.php?t=25903
Probably it misses at the end : “, dz.data.mailTo”
Re: sending email in dzvents script does not work
Posted: Thursday 06 January 2022 22:29
by guenniac
Meanwhile I have tested with this setting:
Code: Select all
data = {
mailTo = { initial = 'root@sau' }
},
....
dz.log(logtext)
dz.email('message from your lockRS script', logtext, dz.data.mailTo) -- this does not work
os.execute("echo '" .. logtext .. "' | mailx -s 'domoticz message' " .. dz.data.mailTo) -- this works
The log shows:
2022-01-06 22:13:44.070 Status: dzVents: Info: lockRS: ------ Start internal script: lockRS: Device: "RS Stop (Virtual)", Index: 377
2022-01-06 22:13:44.071 Status: dzVents: Info: lockRS: RS Timeout - reset by manual action
2022-01-06 22:13:44.209 Status: dzVents: Info: lockRS: ------ Finished lockRS
I have no clue why dz.email does not work, while os.execute works!
Could someone look at it, if you need more infos, please let me know!
Re: sending email in dzvents script does not work
Posted: Thursday 06 January 2022 22:57
by user4563
Do you have 127.0.0.1 whitelisted so it doesn't require a login?
Re: sending email in dzvents script does not work
Posted: Thursday 06 January 2022 23:38
by guenniac
Yes it is in the list!
Re: sending email in dzvents script does not work
Posted: Saturday 08 January 2022 3:32
by user4563
As a side note domoticz.executeShellCommand will execute asynchronously vs the old os.execute :
https://www.domoticz.com/wiki/DzVents:_ ... _execution
I went through all my scripts and changed them as I've read where some others have had issues with not being able to run shell commands asynchronously and sometimes encountered errors/hangs.
Re: sending email in dzvents script does not work
Posted: Saturday 08 January 2022 10:19
by EddyG
@guenniac states that os.execute works fine.
I checked the sending of email by dzVents and it works fine.
Why are you using data to store the emailaddress? Why not just in a variable?
Did you try several emailaddresses?
Re: sending email in dzvents script does not work
Posted: Sunday 09 January 2022 18:23
by guenniac
There's no difference in behavior when I use dz.email. Regardless what I try:
- local address like 'root@sau' or real address to a provider(<name>@vodafone.de)
- address in data or directly in the call (dz.email('message from your lockRS script', logtext, 'root@sau'))
Tests via "Setup -> Settings -> Email":
- with several valid addresses outside it works
- with local address (root@sau) it doesn't
Does dz.email use data from "Setup -> Settings -> Email" and sends email directly to the given email provider?
Re: sending email in dzvents script does not work
Posted: Sunday 09 January 2022 19:55
by EddyG
As server in the email setup I use the smtp server from my provider with port 25.
"root@sau" is not really an emailaddress.
Re: sending email in dzvents script does not work
Posted: Monday 10 January 2022 9:33
by guenniac
You are right. In the settings I have my provider access data set and this works.
When using os.execute mails to "root@sau" will be send directly to my local mailbox. That works!