joshuacox / mkdomoticz

Make a persistent domoticz container PDQ
GNU General Public License v3.0
16 stars 28 forks source link

e-mail notifications do not work from docker container #20

Open lingenavd opened 4 years ago

lingenavd commented 4 years ago

Hello,

I used https://www.domoticz.com/wiki/Docker to install the docker container Domoitcz. I works like a charm exept for the e-mail notifications.

My setup: Raspberry PI 4B with Ubuntu Linux image VERSION="19.10 (Eoan Ermine)" Server: Docker Engine - Community Version: 19.03.3 API version: 1.40 (minimum version 1.12) Go version: go1.12.10 Git commit: a872fc2 Built: Tue Oct 8 00:59:07 2019 OS/Arch: linux/arm64

Your docker container from Dockerhub Domoticz V4.10364

Script to run the container: docker run --name=domoticz_arm \ --privileged \ -d \ --network ip32to63 \ -v /home/ubuntu/terraform/domoticz/datadir/config:/config \ -t joshuacox/mkdomoticz:arm

Email notification errors from the Domoticz log: 2020-02-06 11:03:05.143 Notification sent (email) => Failed 2020-02-06 11:03:05.151 Active notification Subsystems: email (1/13) 2020-02-06 11:03:05.102 Status: Notification: Domoticz test 2020-02-06 11:03:05.143 Error: SMTP Mailer: Error sending Email to: myname@mydomain.com ! 2020-02-06 11:03:05.143 Error: Failed to send Email notification!

I cannot get it to work with auth, without auth for local LAN. not on port 25, not on SSL 465

To make sure the container is able to connect to my local SMTP mail server, I connected to the container and installed telnet. I was able to to connect to my mail server and send an email via telnet from the container in the bash shell.

So I am kind of lost why it won't work from the Domoticz web interface.

Any help is appreciated. Thanx in advance.

grtz, Andre

lingenavd commented 4 years ago

Update: I am aslo able to send mail from a python script within the container. Python is available in the container by default. My workaround is now when I want some action or alert for a Dmoticz event I can use Python script directly in the event module or with the use of blockly you have the possibilty to start a script. So I start a shell script with blockly wich starts the python send-email,py script. With blockly you can also add parameters, so I guess you can use parameters to specify the subject, body or even the recipient (I haven't tested the parameters yet) But this is ofcourse not really convienent to rewrite all events you want notifications for.

So I am really curious what is missing in the Domticz folders to be the cause of the email errors for the standard notification functionality in Domoticz.

grtz, Andre van der Lingen

alan-rpi commented 4 years ago

I have the same problem after I installed on a Rasp Pi 4 (Buster) (note this was an image from http://www.raspberry-asterisk.org/downloads/. + Docker version 19.03.5, build 633a0ea

Using the CLI option in Portainer for the Domoticz container I tried various email functions but none worked:

root@906c589a83bc:/# sendmail user@example.com < /tmp/email.txt bash: sendmail: command not found root@906c589a83bc:/# mail -s "Test Subject" user@example.com < /dev/null bash: mail: command not found root@906c589a83bc:/# mutt -s "Test Email" user@example.com < /dev/null bash: mutt: command not found root@906c589a83bc:/# ssmtp admin@example.com bash: ssmtp: command not found root@906c589a83bc:/#

Looks like no email package has been installed despite the fact this image is 600MB.

I looked at adapting the package with Docker Build but it's beyond my skills and anyway, I don't know if "SMTP Mailer" is one of the above or not.

Pity, as Domoticz was looking promising, especially with Blockly. At least I could access my GPIO pins with this image which I couldn't do with the linuxserver image.

Alan

joshuacox commented 4 years ago

Sorry about all this, I am out of town at the moment, I will remaster this image with the email utilities this weekend. And hopefully figure out some way of automatically building and re-uploading this image.

alan-rpi commented 4 years ago

Thanks for responding so positively. I've also need to send mqtt and in the absence of mqtt in Blockly I wrote a script. That required I install paho-mqtt: sudo pip3 install paho-mqtt . Any chance please you could also add in paho-mqtt when you sort out the email. Best wishes, Alan

lingenavd commented 4 years ago

Thanx mate that would be great!!

I was already on the way to see if I could make a brand new container based on ubuntu:latest to get it working myself. I have never done that that so I am learning docker, git, make, make clean and all other commands.....I have a lot of respect for you to have that knowledge already :-) Let me know what package you added to make it work so, when I eventually get my act together, I can do the same. it is a lot to comprehend, but I like the challenge :-) What I already noticed is that with the current master of open-zwave on github I was not able to complete the "make" of domoticz....I get all kinds of errors regarding open-zwave..... I am still researching and trying different things, but I am not confident I will find a solution....so for the moment I am stuck. Hope you get the e-mail fixed in your container and maybe update to the latest Domotics ass well?

Again, thank you very much for your effort!

with regards, Andre

alan-rpi commented 4 years ago

As a temporary measure I have written a bash & python scripts to send emails from Blockly but I guess it can be used wherever a script can be called. In fact there are 2 sets of scripts, one for emails and one for mqtt messages. More details at my github respository: https://github.com/alan-rpi/domoticz-email-mqtt Note that neither script supports SSL so it will not work with some email hosts. This is my first github repository; a little thank you to all those who have provided lots of free resources that I have used. Alan

CHKDSK88 commented 4 years ago

@joshuacox

Thank You for Your work. Any chance to add email feature for domoticz docker?