Linuxfabrik / monitoring-plugins

200+ check plugins for Icinga and other Nagios-compatible monitoring applications. Each plugin is a standalone command line tool (written in Python) that provides a specific type of check.
https://linuxfabrik.ch
The Unlicense
207 stars 48 forks source link

notify-host-mail: Does not support STARTTLS SMTP servers #752

Open laison007 opened 3 months ago

laison007 commented 3 months ago

This issue respects the following points:

Which variant of the Monitoring Plugins do you use?

Bug description

Hello friends.

I am trying to configure notifications for alarms, to be sent by mail to an address created for that purpose, in Office 365 and I have found that the plugin is not prepared for SMTP servers using STARTTLS, I have checked in the Python documentation that in the library used if STARTTLS is supported, but the script or plugin does not provide for this option.

I offer to test but my Python knowledge is limited.

Best regards.

Here is the error I get when running the notify-host-mail plugin

root@Icinga-Server:/usr/lib64/nagios/plugins# ./notify-host-mail --datetime 03/04/2023-17:00 --host-displayname Icinga-Server --host-state Down --mail-recipient *@****.com --mail-sender *@**.com --short Traceback (most recent call last): File "/usr/lib64/nagios/plugins/./notify-host-mail", line 497, in 'module' main() File "/usr/lib64/nagios/plugins/./notify-host-mail", line 491, in main s.send_message(mail_msg) File "/usr/lib/python3.11/smtplib.py", line 986, in send_message return self.sendmail(from_addr, to_addrs, flatmsg, mail_options, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/smtplib.py", line 887, in sendmail raise SMTPSenderRefused(code, resp, from_addr) smtplib.SMTPSenderRefused: (451, b'5.7.3 STARTTLS is required to send mail [P**.F*.PROD.OUTLOOK.COM 2024-04-04T07:01:48.396Z ****]', '**@**.com')

Link to Python lib smtplib:

https://docs.python.org/3/library/smtplib.html

Steps to reproduce - Plugin call

notify-host-mail --datetime 03/04/2023-17:00 --host-displayname Icinga-Server --host-state Down --mail-recipient *@****.com --mail-sender *@**.com --short

Steps to reproduce - Data

No response

Environment

Linux Icinga-Server 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux

Plugin Version

notify-host-mail: v2023112901 by Linuxfabrik GmbH, Zurich/Switzerland

Python version

Python 3.11.2

List of Python modules

No response

Additional Information

No response