Monit (mail)alerts not working

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Monit (mail)alerts not working

Post by McMelloW »

Raspberry Pi 3B+ BullsEye build 1725 Monit 5.27.2

Installed and configured monit according wiki page https://www.domoticz.com/wiki/Monitoring_domoticz.

Code: Select all

# My mail server configuration on /etc/monit/monitrc

    set mailserver smtp.telfortglasvezel.nl port 587
    username "[email protected]" password "PASSWORD"
    using AUTO
    with timeout 30 seconds
    set alert [email protected]
When this script is active monit sends the following error

Code: Select all

[2024-07-03T13:15:00+0200] info     : 'mcmellow-pi' Monit 5.27.2 started
[2024-07-03T13:15:01+0200] error    : Mail: Mailserver response error -- 501 5.1.7 Bad sender address syntax
[2024-07-03T13:15:01+0200] info     : Adding event to the queue file /var/lib/monit/events/1720005301_55745a71c0 for later delivery
[2024-07-03T13:15:01+0200] error    : Mail: Mailserver response error -- 501 5.1.7 Bad sender address syntax
[2024-07-03T13:15:01+0200] error    : Alert handler failed, retry scheduled for next cycle
The configuration uses the same things as used for Domoticz sending notifications by email. That works OK.
Is there something I overlooked or is wrong?
Greetings McMelloW
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit (mail)alerts not working

Post by Kedi »

Is mail outside Domoticz, like with bash, working?
Because Domoticz has his own smtpclient for sending mail, Monit does not, it uses the system mailclient afaik.
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Monit (mail)alerts not working

Post by McMelloW »

Kedi wrote: Wednesday 03 July 2024 14:27 Is mail outside Domoticz, like with bash, working?
Because Domoticz has his own smtpclient for sending mail, Monit does not, it uses the system mailclient afaik.
Which smtpclient can I use to send mail from a Raspberry Pi
Greetings McMelloW
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit (mail)alerts not working

Post by Kedi »

I use a simple email client -> msmtp
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Monit (mail)alerts not working

Post by McMelloW »

Kedi wrote: Wednesday 03 July 2024 19:27 I use a simple email client -> msmtp
Thanks, I installed the same and after the first commandline test I received the following errors. Shoot me.

Code: Select all

echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t  [email protected]

Code: Select all

<-- 501 5.1.7 Bad sender address syntax
msmtp: envelope from address default not accepted by the server
msmtp: server message: 501 5.1.7 Bad sender address syntax
msmtp: could not send mail (account default from /etc/msmtprc)
Greetings McMelloW
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit (mail)alerts not working

Post by Kedi »

So what's the content of /etc/msmtprc or (what I use) .msmtprc in the home directory.
/etc/msmtprc is the global setting in the home dir is the user setting.
Read the doc. https://marlam.de/msmtp/documentation/

B.t.w. I looked a little bit further in my system (it was a long time ago I configured monit)
It looks now to me that monit can mail internally. https://mmonit.com/monit/documentation/ ... t-delivery
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Monit (mail)alerts not working

Post by McMelloW »

Kedi wrote: Wednesday 03 July 2024 21:10 B.t.w. I looked a little bit further in my system (it was a long time ago I configured monit)
It looks now to me that monit can mail internally. https://mmonit.com/monit/documentation/ ... t-delivery
That is the way it is also explained in the Domoticz wiki. See my first posting.
Greetings McMelloW
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit (mail)alerts not working

Post by Kedi »

Sorry for hasty en not good reaing of your post.
B.t.b. msmtp can help when emailing via bash...

Your error is Bad sender address syntax
I use from: $HOST@<dominename>
Fill your domain instead of the <dominename>

This my setting.

Code: Select all

set mail-format {
  from: $HOST@<domainname>
  subject: $SERVICE $EVENT at $DATE
  message: $EVENT Service $SERVICE
                Date:        $DATE
                Action:      $ACTION
                Host:        $HOST
                Description: $DESCRIPTION

           Your faithful employee,
           Monit }
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Monit (mail)alerts not working

Post by McMelloW »

Kedi wrote: Wednesday 03 July 2024 22:35 Sorry for hasty en not good reaing of your post.
B.t.b. msmtp can help when emailing via bash...

Your error is Bad sender address syntax
I use from: $HOST@<dominename>
Fill your domain instead of the <dominename>

This my setting.

Code: Select all

set mail-format {
  from: $HOST@<domainname>
  subject: $SERVICE $EVENT at $DATE
  message: $EVENT Service $SERVICE
                Date:        $DATE
                Action:      $ACTION
                Host:        $HOST
                Description: $DESCRIPTION

           Your faithful employee,
           Monit }
What did you used as mailserver configuration in your monitrc
Greetings McMelloW
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Monit (mail)alerts not working

Post by waltervl »

Just a workaround: I use Domoticz own notify functions to notify me when Domoticz has been (re)started with the following dzvents script . https://www.domoticz.com/forum/viewtopic.php?t=25209
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit (mail)alerts not working

Post by Kedi »

You can't use Domoticz notification system if Domoticz is somehow not responding anymore.

My server setting is:

Code: Select all

set mailserver smtp.ziggo.nl port 587 username <emailname>@ziggo.nl password '<password>' using SSL with timeout 30 seconds
I have my password between single quotes.
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Monit (mail)alerts not working

Post by waltervl »

If Domoticz server is not responding it will be restarted by monit and Domoticz will send the notification.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Monit (mail)alerts not working

Post by McMelloW »

waltervl wrote: Thursday 04 July 2024 16:26 If Domoticz server is not responding it will be restarted by monit and Domoticz will send the notification.
Thanks for your reply.
Yes, that is working OK. Domoticz does send a notification when restarted. But I do monitor others running services as well with Monit Therefor I will have the Monit mailserver up and running.
Greetings McMelloW
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Monit (mail)alerts not working

Post by Kedi »

@waltervl Your right. But then you get an email every time Domoticz is (re)started and there is no notification about the cause.
With Monit you can, and even monitor other processes on the same way.
That is why I use Monit, because Domoticz by default does not monitor my tmpfs /var/log and other processes that are in my case vital to Domoticz like Mosquitto and Node-Red and Zigbee2MQTT.
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Monit (mail)alerts not working

Post by waltervl »

Understood. It was just a workaround for Monit email notification for Domoticz. Currently my system is very stable so no need to know why..... ;-)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Monit (mail)alerts not working

Post by McMelloW »

Thanks for all the input, back to my first post.

Does anybody have a hint to get sending mail from monit mail server working?
Greetings McMelloW
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Monit (mail)alerts not working

Post by waltervl »

Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Monit (mail)alerts not working

Post by jvdz »

Try something like this as it seems your sender address is wrong:

Code: Select all

  # My mail server configuration on /etc/monit/monitrc
set mail-format {
      from: MonitPi<[email protected]>
   subject: $SERVICE $EVENT at $DATE
   message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
			Yours sincerely,
            monit
 }

set mailserver smtp.telfortglasvezel.nl port 587
username "[email protected]" password "PASSWORD"
using AUTO
with timeout 30 seconds
set alert [email protected]
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest