Troubleshooting Monit Email alerts

Is monit still capable of email alerts?

I setup mail service in System-Mailservice, and I get test emails
I even get APC-UPS alerts with email.

For some unknown reason, I can’t get Monit to send emails. I set it up in /etc/monitrc

set mailserver mail.google.com port 465
username “login”
password “password000”
using auto

Where would you see any anomalies regarding Monit trying to send emails?

I am using @jon 's firewall alerts. and they work pretty good, I see them in System Logs but no emails.

this is what I have for gmail:

SET MAILSERVER
	smtp.gmail.com
	PORT 587
	USERNAME <username without domain>
	PASSWORD <password>
	using tls

and then this:

SET ALERT example@gmail.com with reminder on nn cycles
1 Like

Thanks Jon, I forgot to use
SET ALERT...
now it’s trying to send but looks like has a bug:

12:02:45	monit[2041]: 	SMTP: Mailserver response error -- 550-The mail server does not recognize monit@ ipfire.lan as a valid sender.
12:02:46	monit[2041]: 	Alert handler failed, retry scheduled for next cycle 

that is seems to be a bug in “monit” because
I have

set mail-format {
	from: ipfire@mailserver.com

even after reload, and restart

here is my mail-format. This is what I’ve used and it works !

SET MAIL-FORMAT {
from:    Monit <monit@$HOST>
subject: Monit alert on $HOST  --  $EVENT $SERVICE
message: $EVENT on the service: $SERVICE
	
Date:         $DATE
Action:       $ACTION
Host:         $HOST
Description:  $DESCRIPTION
}

Nothing has been changed above. Try adding this to your file exactly as-is and see if it works.

Thanks for trying Jon :+1:

I copied it exactly as-is and got an error:

root@IPFIRE # monit reload

'etc/monitrc:65: invalid mail format '
'etc/monit.d/monit2.cfg:67: syntax error 'subject: Monit alert on $HOST  --  $EVENT $SERVICE

In the first error:

It points to the etc/monitrc file and line 65. Open the etc/monitrc file and check the line 65 (and maybe a few above).

EDIT:
As a general practice with monit – Before doing a reload do a monit -t to check the configuration files.

2 Likes

Thank you,
I just redid the whole monitrc file,

and monit -t is very useful thank you again

Unfortunately mail server is refusing to send the alerts because the
“sender” (monit@IPFIRE.lan) is not a valid email address (ipfire@email.com)


Mail: Mailserver response error -- 550-Verification failed for <monit@IPFIRE.lan>

monit[13539]: 	SMTP: Mailserver response error -- 550-The mail server does not recognize monit@ ipfire.lan as a valid sender.

I am not sure… (this is beyond my skills)

You’ll probably need to contact monit support for assistance or do a giggle search for the error.

1 Like