Page 1 of 1
Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 14:22
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?
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 14:27
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.
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 19:04
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
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 19:27
by Kedi
I use a simple email client -> msmtp
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 20:36
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
<-- 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)
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 21:10
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
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 22:18
by McMelloW
That is the way it is also explained in the Domoticz wiki. See my first posting.
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 22:35
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 }
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 22:59
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
Re: Monit (mail)alerts not working
Posted: Wednesday 03 July 2024 23:03
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
Re: Monit (mail)alerts not working
Posted: Thursday 04 July 2024 10:18
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.
Re: Monit (mail)alerts not working
Posted: Thursday 04 July 2024 16:26
by waltervl
If Domoticz server is not responding it will be restarted by monit and Domoticz will send the notification.
Re: Monit (mail)alerts not working
Posted: Thursday 04 July 2024 18:22
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.
Re: Monit (mail)alerts not working
Posted: Thursday 04 July 2024 18:24
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.
Re: Monit (mail)alerts not working
Posted: Thursday 04 July 2024 23:09
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.....

Re: Monit (mail)alerts not working
Posted: Thursday 11 July 2024 9:31
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?
Re: Monit (mail)alerts not working
Posted: Thursday 11 July 2024 10:34
by waltervl
Re: Monit (mail)alerts not working
Posted: Thursday 11 July 2024 11:06
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]