sending email in dzvents script does not work

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
guenniac
Posts: 23
Joined: Wednesday 27 October 2021 18:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Aachen, Germany
Contact:

sending email in dzvents script does not work

Post 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
Raspberry Pi 3B+
Raspbian GNU/Linux 12 (bookworm) / 6.1.61-v7+
Version: 2023.2
Build Hash: 19efd039c
Compile Date: 2023-07-21 17:23:44
dzVents Version: 3.1.8
Python Version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
guenniac
Posts: 23
Joined: Wednesday 27 October 2021 18:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Aachen, Germany
Contact:

Re: sending email in dzvents script does not work

Post by guenniac »

Isn't there really nobody with an idea?
Any hints are really appreciated!
Raspberry Pi 3B+
Raspbian GNU/Linux 12 (bookworm) / 6.1.61-v7+
Version: 2023.2
Build Hash: 19efd039c
Compile Date: 2023-07-21 17:23:44
dzVents Version: 3.1.8
Python Version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: sending email in dzvents script does not work

Post by madpatrick »

You can check this thread
https://domoticz.com/forum/viewtopic.php?t=25903

Probably it misses at the end : “, dz.data.mailTo”
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
guenniac
Posts: 23
Joined: Wednesday 27 October 2021 18:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Aachen, Germany
Contact:

Re: sending email in dzvents script does not work

Post 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!
Raspberry Pi 3B+
Raspbian GNU/Linux 12 (bookworm) / 6.1.61-v7+
Version: 2023.2
Build Hash: 19efd039c
Compile Date: 2023-07-21 17:23:44
dzVents Version: 3.1.8
Python Version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
User avatar
user4563
Posts: 110
Joined: Tuesday 19 October 2021 17:24
Target OS: Linux
Domoticz version: 2025.1
Contact:

Re: sending email in dzvents script does not work

Post by user4563 »

Do you have 127.0.0.1 whitelisted so it doesn't require a login?
ODroid H4+ / Ubuntu server 24.04 LTS
Aeotec Z-Stick Gen5+
ZWave-JS-UI / Mosquitto MQTT
Domoticz for Android
Domoticz Scenes add-on in Kodi
guenniac
Posts: 23
Joined: Wednesday 27 October 2021 18:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Aachen, Germany
Contact:

Re: sending email in dzvents script does not work

Post by guenniac »

Yes it is in the list!
Raspberry Pi 3B+
Raspbian GNU/Linux 12 (bookworm) / 6.1.61-v7+
Version: 2023.2
Build Hash: 19efd039c
Compile Date: 2023-07-21 17:23:44
dzVents Version: 3.1.8
Python Version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
User avatar
user4563
Posts: 110
Joined: Tuesday 19 October 2021 17:24
Target OS: Linux
Domoticz version: 2025.1
Contact:

Re: sending email in dzvents script does not work

Post 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.
ODroid H4+ / Ubuntu server 24.04 LTS
Aeotec Z-Stick Gen5+
ZWave-JS-UI / Mosquitto MQTT
Domoticz for Android
Domoticz Scenes add-on in Kodi
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: sending email in dzvents script does not work

Post 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?
guenniac
Posts: 23
Joined: Wednesday 27 October 2021 18:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Aachen, Germany
Contact:

Re: sending email in dzvents script does not work

Post 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?
Raspberry Pi 3B+
Raspbian GNU/Linux 12 (bookworm) / 6.1.61-v7+
Version: 2023.2
Build Hash: 19efd039c
Compile Date: 2023-07-21 17:23:44
dzVents Version: 3.1.8
Python Version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: sending email in dzvents script does not work

Post 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.
guenniac
Posts: 23
Joined: Wednesday 27 October 2021 18:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Aachen, Germany
Contact:

Re: sending email in dzvents script does not work

Post 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!
Raspberry Pi 3B+
Raspbian GNU/Linux 12 (bookworm) / 6.1.61-v7+
Version: 2023.2
Build Hash: 19efd039c
Compile Date: 2023-07-21 17:23:44
dzVents Version: 3.1.8
Python Version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest